Ejemplo n.º 1
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 + "]");
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public static bool Delete(int leavePlanId)
 {
     try
     {
         ATSCEEntities context   = new ATSCEEntities();
         LeavePlan     leaveplan = context.LeavePlans.Find(leavePlanId);
         context.LeavePlans.Remove(leaveplan);
         context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 6
0
 public static bool Delete(int id)
 {
     try
     {
         ATSCEEntities   context = new ATSCEEntities();
         TimeSheetMaster master  = context.TimeSheetMasters.Find(id);
         context.TimeSheetMasters.Remove(master);
         context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 7
0
        public static IEnumerable <LeavePlan> AdmitOrRejectLeaves(int LeavePlanId, bool AdmitReject)
        {
            ATSCEEntities context       = new ATSCEEntities();
            LeavePlan     leaveToUpdate = context.LeavePlans.Where(lp => lp.LeavePlanId == LeavePlanId).FirstOrDefault();

            if (AdmitReject)
            {
                leaveToUpdate.Admitted = true;
            }
            else
            {
                leaveToUpdate.Admitted = false;
            }
            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception("Could not admit or reject [" + ex.Message + "]");
            }

            return(GetAllLeavePlansBySupervisorId(int.Parse((leaveToUpdate.Person as Staff).SupervisorId.ToString())));
        }