Пример #1
0
        public async Task <CreatorSet> addCreatorWorkingHours(CreatorSet creatorSet, DateTime workinghoursSet, DateTime addStartWorkingHourSet, DateTime addEndWorkingHourSet)
        {
            return(await Task.Factory.StartNew(() =>
            {
                using (CasierContents context = new CasierContents())
                {
                    //   DateTime saveNow =

                    WorkinghoursSet workingHourset = new WorkinghoursSet();

                    workingHourset.StartHour = new DateTime(workinghoursSet.Year, workinghoursSet.Month, workinghoursSet.Day, addStartWorkingHourSet.Hour, addStartWorkingHourSet.Minute, 0);

                    workingHourset.EndHour = new DateTime(workinghoursSet.Year, workinghoursSet.Month, workinghoursSet.Day, addEndWorkingHourSet.Hour, addEndWorkingHourSet.Minute, 0);;

                    var findCreatorSet = context.CreatorSet.Include("WorkinghoursSet").Where(x => x.CreatorId == creatorSet.CreatorId).FirstOrDefault();

                    foreach (var workinghours in findCreatorSet.WorkinghoursSet.ToList())
                    {
                        if (workinghours.StartHour.Value.Date != workingHourset.StartHour.Value.Date)
                        {
                            findCreatorSet.WorkinghoursSet.Add(workingHourset);
                            context.SaveChanges();
                            break;
                        }
                    }

                    return findCreatorSet;
                    //&& u.WorkinghoursSet.(y => y.StartHour.Value.Date == DateTime.Now.Date)
                }
            }));
        }
Пример #2
0
        public async System.Threading.Tasks.Task <ActionResult> RemoveTimeReg(WorkinghoursSet workinghoursSet)
        {
            var results = await catalog.RemoveTimeReg(workinghoursSet);

            return(Json(JsonConvert.SerializeObject(results, new JsonSerializerSettings()
            {
                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            }), JsonRequestBehavior.AllowGet));
        }
Пример #3
0
 public async Task <WorkinghoursSet> SaveTimeReg(WorkinghoursSet workinghoursSet)
 {
     return(await Task.Factory.StartNew(() =>
     {
         using (CasierContents context = new CasierContents())
         {
             var getItems = context.WorkinghoursSet.Where(x => x.WorkingHoursId == workinghoursSet.WorkingHoursId).FirstOrDefault();
             getItems.StartHour = workinghoursSet.StartHour;
             getItems.EndHour = workinghoursSet.EndHour;
             context.SaveChanges();
             return getItems;
         }
     }));
 }
Пример #4
0
        public async Task <WorkinghoursSet> CreatorsCheckIn(CreatorSet creator)
        {
            return(await Task.Factory.StartNew(() =>
            {
                using (CasierContents context = new CasierContents())
                {
                    var findCreator = context.CreatorSet.Where(x => x.CreatorId == creator.CreatorId).FirstOrDefault();

                    var findWorkingHourExist = context.WorkinghoursSet.Where(x => findCreator.CreatorId == x.CreatorSet.CreatorId).ToList();

                    WorkinghoursSet findToworkingHours = null;



                    foreach (var workinghours in findWorkingHourExist)
                    {
                        if (workinghours.StartHour != null)
                        {
                            if (workinghours.StartHour.Value.Date == DateTime.Now.Date)
                            {
                                findToworkingHours = workinghours;
                            }
                        }
                    }

                    //    x.StartHour.Value.Date.Month == DateTime.Now.Date.Month && x.StartHour.Value.Year == DateTime.Now.Date.Year && x.StartHour.Value.Date.Day == DateTime.Now.Date.Day

                    if (findToworkingHours == null)
                    {
                        WorkinghoursSet workingourset = new WorkinghoursSet();
                        workingourset.StartHour = DateTime.Now;
                        findCreator.WorkinghoursSet.Add(workingourset);
                        context.SaveChanges();
                        return workingourset;
                    }
                    else if (findToworkingHours != null)
                    {
                        findToworkingHours.StartHour = DateTime.Now;
                        context.SaveChanges();
                        return findToworkingHours;
                    }
                    return null;
                }
            }));
        }
Пример #5
0
        public async Task <CreatorSet> CreatorsCheckOut(CreatorSet creator, WorkinghoursSet workinghoursSet)
        {
            return(await Task.Factory.StartNew(() =>
            {
                using (CasierContents context = new CasierContents())
                {
                    /*  var findTheCurrentworkinghoursSet = context.WorkinghoursSet.Where(x => x.WorkingHoursId == creator.WorkinghoursSet.First()).FirstOrDefault();*/



                    var workinghour = context.WorkinghoursSet.Find(workinghoursSet.WorkingHoursId);
                    if (workinghour.EndHour == null && workinghour.StartHour.Value.Date == DateTime.Now.Date)
                    {
                        workinghour.EndHour = DateTime.Now;
                        context.SaveChanges();
                    }
                    return creator;
                }
            }));
        }