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) } })); }
public async System.Threading.Tasks.Task <ActionResult> GetWorkinghours(CreatorSet creator, DateTime WorkinghoursSetStartDate, DateTime WorkinghoursSetEndDate) { var results = await catalog.GetWorkinghours(creator, WorkinghoursSetStartDate, WorkinghoursSetEndDate); return(Json(JsonConvert.SerializeObject(results, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }), JsonRequestBehavior.AllowGet)); }
public async System.Threading.Tasks.Task <ActionResult> CreatorsCheckOut(CreatorSet creator, WorkinghoursSet workinghoursSet) { var results = await catalog.CreatorsCheckOut(creator, workinghoursSet); return(Json(JsonConvert.SerializeObject(results, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }), JsonRequestBehavior.AllowGet)); }
public async System.Threading.Tasks.Task <ActionResult> GetAndUpdateCreators(CreatorSet creator) { var results = await catalog.GetAndUpdateCreators(creator); return(Json(JsonConvert.SerializeObject(results, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }), JsonRequestBehavior.AllowGet)); }
public async Task <bool> DeleteCreatorSet(CreatorSet creatorSet) { return(await Task.Factory.StartNew(() => { using (CasierContents context = new CasierContents()) { var deleteItemReservationSet = context.CreatorSet.Find(creatorSet.CreatorId); deleteItemReservationSet.CPR = null; context.SaveChanges(); return true; } })); }
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; } })); }
public async Task <IEnumerable <WorkinghoursSet> > GetWorkinghours(CreatorSet creator, DateTime WorkinghoursSetStartDate, DateTime WorkinghoursSetEndDate) { return(await Task.Factory.StartNew(() => { using (CasierContents context = new CasierContents()) { if (creator == null) { var getItems = context.WorkinghoursSet.Include("CreatorSet").Where(u => u.StartHour.Value.Date <= WorkinghoursSetStartDate.Date && u.StartHour.Value.Date >= WorkinghoursSetEndDate.Date).ToList(); return getItems; } else { var getItems = context.WorkinghoursSet.Include("CreatorSet").Where(u => u.StartHour.Value.Date <= WorkinghoursSetStartDate.Date && u.StartHour.Value.Date >= WorkinghoursSetEndDate.Date && creator.CreatorId == u.CreatorSet.CreatorId).ToList(); return getItems; } } })); }
public async Task <CreatorSet> GetAndUpdateCreators(CreatorSet creator) { return(await Task.Factory.StartNew(() => { using (CasierContents context = new CasierContents()) { // check the dubllicate date. var existedItem = context.CreatorSet.Include("WorkinghoursSet").Where(u => u.CPR != null && u.CreatorId == creator.CreatorId).FirstOrDefault(); if (existedItem != null) { existedItem.BankInfo = creator.BankInfo; existedItem.CPR = creator.CPR; existedItem.Description = creator.Description; existedItem.Evaluation = creator.Evaluation; existedItem.HourSalary = creator.HourSalary; existedItem.MonthSalary = creator.MonthSalary; existedItem.Name = creator.Name; existedItem.Phone = creator.Phone; existedItem.WorkinghoursSet = creator.WorkinghoursSet; context.SaveChanges(); return existedItem; } else { CreatorSet newCreatorSet = new CreatorSet(); newCreatorSet.BankInfo = creator.BankInfo; newCreatorSet.CPR = creator.CPR; newCreatorSet.Description = creator.Description; newCreatorSet.Evaluation = creator.Evaluation; newCreatorSet.HourSalary = creator.HourSalary; newCreatorSet.MonthSalary = creator.MonthSalary; newCreatorSet.Name = creator.Name; newCreatorSet.Phone = creator.Phone; newCreatorSet.WorkinghoursSet = creator.WorkinghoursSet; context.CreatorSet.Add(newCreatorSet); context.SaveChanges(); return newCreatorSet; } } })); }
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; } })); }
public async System.Threading.Tasks.Task <ActionResult> addCreatorWorkingHours(CreatorSet creatorSet, DateTime workingHourDate, DateTime addStartWorkingHourSet, DateTime addEndWorkingHourSet) { var results = await catalog.addCreatorWorkingHours(creatorSet, workingHourDate, addStartWorkingHourSet, addEndWorkingHourSet); return(Json(JsonConvert.SerializeObject(results, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }), JsonRequestBehavior.AllowGet)); }