ATS.Data.Model.CodeTable.Save C# (CSharp) Метод

Save() публичный Метод

public Save ( ) : string
Результат string
        public string Save()
        {
            string result = string.Empty;
            try
            {
                using (var context = new ATSCEEntities())
                {
                    if (this.CodeTableId <= 0)
                    {
                        context.CodeTables.Add(this);
                    }
                    else
                    {
                        context.Entry(this).State = System.Data.EntityState.Modified;
                    }
                    int rowAffected = context.SaveChanges();

                    if (rowAffected <= 0)
                        result = "Record is not saved";
                }
            }
            catch (Exception ex)
            {
                // Log Exception here.
                throw new Exception("Record is not saved");
            }

            return result;
        }