Beispiel #1
0
 public static IEnumerable <CodeTable> GetAll()
 {
     using (var context = new ATSCEEntities())
     {
         return(context.CodeTables.ToList());
     }
 }
Beispiel #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;
        }
Beispiel #3
0
 public static CodeTable GetById(int codeTableId)
 {
     using (var context = new ATSCEEntities())
     {
         return(context.CodeTables.Single(r => r.CodeTableId == codeTableId));
     }
 }
Beispiel #4
0
 public static CodeTable GetById(int codeTableId)
 {
     using (var context = new ATSCEEntities())
     {
         return context.CodeTables.Single(r => r.CodeTableId == codeTableId);
     }
 }
        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);
        }
Beispiel #6
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);
        }
Beispiel #7
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 + "]");
            }
        }
Beispiel #8
0
 public static IEnumerable<CodeTable> GetAll()
 {
     using (var context = new ATSCEEntities())
     {
         return context.CodeTables.ToList();
     }
 }
Beispiel #9
0
        public static IEnumerable <LeavePlan> GetAllLeavePlansForTeam(int userId)
        {
            ATSCEEntities           context = new ATSCEEntities();
            IEnumerable <LeavePlan> leaves  = from allLeavePlans in context.LeavePlans
                                              where (allLeavePlans.Person as Staff).SupervisorId == userId
                                              select allLeavePlans;

            return(leaves);
        }
Beispiel #10
0
        public static IEnumerable <LeavePlan> GetAllLeavePlansBySupervisorId(int id)
        {
            ATSCEEntities           context           = new ATSCEEntities();
            IEnumerable <LeavePlan> leavesToSupervise = from allLeavePlans in context.LeavePlans
                                                        where (allLeavePlans.Person as Staff).SupervisorId == id
                                                        where allLeavePlans.Admitted == null
                                                        select allLeavePlans;

            return(leavesToSupervise);
        }
 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);
     }
 }
Beispiel #12
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);
     }
 }
Beispiel #13
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())));
        }
Beispiel #14
0
        public static Person GetById(int PersonId)
        {
            ATSCEEntities context = new ATSCEEntities();

            return(context.Persons.Find(PersonId));
        }
        public static TimeSheetMaster GetById(int TimeSheetMasterId)
        {
            ATSCEEntities context = new ATSCEEntities();

            return(context.TimeSheetMasters.Find(TimeSheetMasterId));
        }
        public static IEnumerable <TimeSheetMaster> GetAll()
        {
            ATSCEEntities context = new ATSCEEntities();

            return(context.TimeSheetMasters);
        }
Beispiel #17
0
        public static IEnumerable <LeaveCategory> getAll()
        {
            ATSCEEntities context = new ATSCEEntities();

            return(context.LeaveCategories);
        }
Beispiel #18
0
        public static IEnumerable <LeavePlan> GetAll()
        {
            ATSCEEntities context = new ATSCEEntities();

            return(context.LeavePlans.Include(l => l.LeaveCategory).Include(l => l.Person));
        }
Beispiel #19
0
        public static LeavePlan GetById(int leavePlanId)
        {
            ATSCEEntities context = new ATSCEEntities();

            return(context.LeavePlans.Find(leavePlanId));
        }
Beispiel #20
0
        public static TimeSheetDetail GetById(int TimeSheetDetailId)
        {
            ATSCEEntities context = new ATSCEEntities();

            return(context.TimeSheetDetails.Find(TimeSheetDetailId));
        }
Beispiel #21
0
        public static IEnumerable <Person> GetAll()
        {
            ATSCEEntities context = new ATSCEEntities();

            return(context.Persons);
        }