Пример #1
0
        public static Shift Create(Shift shift)
        {
            if (shift.WorkerId == Guid.Empty)
            {
                throw new NullReferenceException("WorkerId");
            }

            if (shift.ShiftTypeEnum.In(eShiftType.NotSet))
            {
                throw new NullReferenceException("ShiftType");
            }

            if (shift.Date == null)
            {
                throw new NullReferenceException("Date");
            }

            using (var appDC = BARDBDataContext.Ready())
            {
                shift.DateCreated = DateTime.Now;
                shift.ShiftId     = Guid.NewGuid();
                shift.ShiftType   = (int)shift.ShiftTypeEnum;

                appDC.Shifts.InsertOnSubmit(shift);
                appDC.SubmitChanges();
                return(shift);
            }
        }
Пример #2
0
 public static Shift Get(DateTime date, eShiftType shiftType, Guid businessUnitId)
 {
     using (var appDC = BARDBDataContext.Ready())
     {
         return(appDC.Shifts.FirstOrDefault(s => s.Date.Date == date.Date && s.ShiftType == (int)shiftType && s.BusinessUnitId == businessUnitId));
     }
 }
Пример #3
0
 public static List <usp_get_shiftsResult> GetList(DateTime dateTime)
 {
     using (var appDC = BARDBDataContext.Ready())
     {
         return(appDC.usp_get_shifts(dateTime).OrderBy(s => s.ShiftType).ToList());
     }
 }
Пример #4
0
 public static bool IsExist(DateTime date, eShiftType shiftType, Guid businessUnitId)
 {
     using (var appDC = BARDBDataContext.Ready())
     {
         return(appDC.Shifts.SingleOrDefault(s => s.Date.Date == date.Date && s.ShiftType == (int)shiftType && s.BusinessUnitId == businessUnitId) != null);
     }
 }
Пример #5
0
 public static List <User> GetList()
 {
     using (var appDC = BARDBDataContext.Ready())
     {
         return(appDC.Users.OrderBy(u => u.FirstName).ToList());
     }
 }
Пример #6
0
 public static User GetById(Guid id)
 {
     using (var appDC = BARDBDataContext.Ready())
     {
         return(appDC.Users.SingleOrDefault(u => u.UserId == id));
     }
 }
Пример #7
0
        public static void Delete(Guid id)
        {
            using (var appDC = BARDBDataContext.Ready())
            {
                var toDelete = appDC.Shifts.SingleOrDefault(s => s.ShiftId == id);

                if (toDelete != null)
                {
                    appDC.Shifts.DeleteOnSubmit(toDelete);
                    appDC.SubmitChanges();
                }
            }
        }
Пример #8
0
        public static void Delete(DateTime date, eShiftType shiftType, Guid businessUnitId)
        {
            using (var appDC = BARDBDataContext.Ready())
            {
                var toDelete = appDC.Shifts.FirstOrDefault(s => s.Date.Date == date.Date && s.ShiftType == (int)shiftType && s.BusinessUnitId == businessUnitId);

                if (toDelete != null)
                {
                    appDC.Shifts.DeleteOnSubmit(toDelete);
                    appDC.SubmitChanges();
                }
            }
        }
Пример #9
0
        public static User Create(User user)
        {
            user.DateCreated = DateTime.Now;
            user.UserId      = Guid.NewGuid();
            user.Password    = "******";

            using (var appDC = BARDBDataContext.Ready())
            {
                appDC.Users.InsertOnSubmit(user);
                appDC.SubmitChanges();
            }

            return(user);
        }
Пример #10
0
        public static void Update(User user)
        {
            using (var appDC = BARDBDataContext.Ready())
            {
                var toUpdate = appDC.Users.SingleOrDefault(u => u.UserId == user.UserId);

                toUpdate.LastName  = user.LastName;
                toUpdate.FirstName = user.FirstName;
                toUpdate.ColorHex  = user.ColorHex;

                if (user.AvatarData != null)
                {
                    toUpdate.AvatarData = user.AvatarData;
                }

                appDC.SubmitChanges();
            }
        }