Ejemplo n.º 1
0
        public ActionResult SetBranchTime(BranchWorkingTimeModel config)
        {
            int BranchId = int.Parse(User.GetClaims("BranchId"));
            var response = service.SetBranchTime(config, User.GetUserId(), BranchId);

            return(Ok(response));
        }
        public IResponse SetBranchTime(BranchWorkingTimeModel workingTime, int ManagerId, int BranchId)
        {
            var ServerDateTime     = DateTime.Now.AddServerTimeHours();
            var SelectedBranchTime = UOW.BranchConfigurations.SingleOrDefault(bc => bc.BranchId == BranchId && bc.CreatedAt.Date == ServerDateTime.Date);

            if (SelectedBranchTime != null)
            {
                SelectedBranchTime.StartTime   = TimeSpan.Parse(workingTime.Start);
                SelectedBranchTime.EndTime     = TimeSpan.Parse(workingTime.End);
                SelectedBranchTime.UpdatedById = ManagerId;
            }
            else
            {
                UOW.BranchConfigurations.Add(new BranchConfiguration()
                {
                    StartTime = TimeSpan.Parse(workingTime.Start), EndTime = TimeSpan.Parse(workingTime.End), BranchId = BranchId, CreatedById = ManagerId
                });
            }
            UOW.Compelete();
            return(response);
        }