Example #1
0
        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;
        }
Example #2
0
        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);
        }
Example #3
0
        public static LeavePlan Save(LeavePlan leavePlan)
        {
            string result = string.Empty;

            try
            {
                ATSCEEntities context = new ATSCEEntities();
                if (leavePlan.LeavePlanId <= 0)
                {
                    context.LeavePlans.Add(leavePlan);
                }
                else
                {
                    context.Entry(leavePlan).State = System.Data.EntityState.Modified;
                }
                int rowAffected = context.SaveChanges();

                if (rowAffected <= 0)
                {
                    result = "Record is not saved";
                }
                return(leavePlan);
            }
            catch (Exception ex)
            {
                throw new Exception("Record is not saved [" + ex.Message + "]");
            }
        }
        public string Save()
        {
            string result = string.Empty;

            try
            {
                using (var context = new ATSCEEntities())
                {
                    if (this.TimeSheetMasterId <= 0)
                    {
                        context.TimeSheetMasters.Add(this);
                    }
                    else
                    {
                        context.Entry(this).State = System.Data.EntityState.Modified;
                    }

                    context.SaveChanges();

                    foreach (TimeSheetDetail detail in this.TimeSheetDetail.ToList())
                    {
                        detail.Save();
                    }
                }
            }
            catch (Exception)
            {
                throw new Exception("Record is not saved");
            }

            return(result);
        }