Пример #1
0
        public virtual IActionResult Create(ShiftModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShifts))
            {
                return(AccessDeniedView());
            }

            if (!string.IsNullOrWhiteSpace(model.Code) && _shiftService.GetShift(w => w.Code == model.Code) != null)
            {
                ModelState.AddModelError(string.Empty, _localizationService.GetResource("Hero.Admin.Shifts.CodeIsRegister"));
            }


            if (ModelState.IsValid)
            {
                var shift = model.ToEntity <Shift>();
                shift.CreatedOnUtc = DateTime.UtcNow;
                shift.CreatedBy    = _workContext.CurrentCustomer.Id;
                shift.UpdatedBy    = null;
                shift.UpdatedOnUtc = null;
                _shiftService.InsertShift(shift);

                //activity log
                _customerActivityService.InsertActivity("AddNewShift",
                                                        string.Format(_localizationService.GetResource("ActivityLog.AddNewShift"), shift.Id), shift);

                SuccessNotification(_localizationService.GetResource("Hero.Admin.Shifts.Added"));

                if (!continueEditing)
                {
                    return(RedirectToAction("List"));
                }

                //selected tab
                SaveSelectedTabName();

                return(RedirectToAction("Edit", new { id = shift.Id }));
            }

            //prepare model
            model = _shiftModelFactory.PrepareShiftModel(model, null, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #2
0
        public async Task <IActionResult> Create(ShiftEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var shift = new ShiftModel
            {
                ShiftName = model.ShiftName,
                StartTime = model.StartTime,
                EndTime   = model.EndTime
            };

            await _shiftService.AddAsync(shift);

            return(RedirectToAction(nameof(Index)));
        }
Пример #3
0
        public Shift Convert(ShiftModel shift)
        {
            var newShift = new Shift();

            if (shift != null)
            {
                newShift.ID = shift.ID;

                newShift.Name = shift.Name;

                newShift.InitialHour = shift.InitialHour;

                newShift.EndingHour = shift.EndingHour;
            }


            return(newShift);
        }
Пример #4
0
        public ActionResult Add(ShiftModel shiftModel)
        {
            try
            {
                shiftModel.AddShift();
                TempData["message"]   = "Successfully added Branch.";
                TempData["alertType"] = "success";
            }

            catch (Exception e)
            {
                TempData["message"]   = "Failed to Add Shift.";
                TempData["alertType"] = "danger";
                Console.Write(e.Message);
            }

            return(RedirectToAction("Index"));
        }
Пример #5
0
        public async Task UpdateShiftAsync(string teamId, ShiftModel shift)
        {
            Guard.ArgumentNotNullOrEmpty(shift.TeamsSchedulingGroupId, nameof(ShiftModel.TeamsSchedulingGroupId));
            Guard.ArgumentNotNullOrEmpty(shift.TeamsEmployeeId, nameof(ShiftModel.TeamsEmployeeId));

            var client = _clientFactory.CreateClient(_options, teamId);

            // get the existing shift from Teams
            var teamsShift = await client.GetShiftAsync(teamId, shift.TeamsShiftId).ConfigureAwait(false);

            teamsShift.SchedulingGroupId = shift.TeamsSchedulingGroupId;
            teamsShift.UserId            = shift.TeamsEmployeeId;
            teamsShift.SharedShift       = _shiftMap.MapShift(shift);

            var response = await client.ReplaceShiftAsync(teamsShift, teamId, teamsShift.Id).ConfigureAwait(false);

            response.ThrowIfError();
        }
Пример #6
0
        // Create new shift
        public static int CreateShift(int shiftId, string shiftRole, string shiftStart,
                                      string shiftEnd, int empId, string shiftDate)
        {
            ShiftModel data = new ShiftModel
            {
                ShiftID    = shiftId,
                ShiftRole  = shiftRole,
                ShiftStart = shiftStart,
                ShiftEnd   = shiftEnd,
                EmployeeID = empId,
                ShiftDate  = shiftDate
            };

            string sql = @"insert into dbo.Shifts (ShiftId, ShiftRole, ShiftStart, ShiftEnd, EmployeeId, ShiftDate)
                            values (@ShiftID, @ShiftRole, @ShiftStart, @ShiftEnd, @EmployeeID, @ShiftDate);";

            return(SQLDataAccess.SaveData(sql, data));
        }
Пример #7
0
        public HttpResponseMessage shiftList([FromBody] ShiftModel objShift)
        {
            //cmd.CommandType = CommandType.StoredProcedure;


            //cmd.Parameters.AddWithValue("@Command","SHIFTLIST");
            //cmd.Parameters.AddWithValue("@status",1);



            var resp = Request.CreateResponse <LoginResponseModel>(HttpStatusCode.OK,
                                                                   new LoginResponseModel()
            {
                message = "ok succesful", statuscode = Convert.ToInt16(HttpStatusCode.OK)
            });

            return(resp);
        }
        public async Task <IActionResult> UpdateShift(int shiftId, ShiftModel model)
        {
            var shift = await _shiftRepository.GetShift(shiftId);

            if (shift == null)
            {
                return(new NotFoundResult());
            }

            shift.Update(model);
            if (await _shiftRepository.IsEmployeeAlreadyAssignedAShift(shift, shift.EmployeeId))
            {
                return(new BadRequestObjectResult("A shift is already assigned to the employee."));
            }

            await _shiftRepository.SaveChanges();

            return(new OkResult());
        }
        private async Task <bool> ManagerApproveAsync(ShiftModel openShift, string newWfmShiftId, OpenShiftsChangeRequest openShiftRequest, ChangeRequest changeRequest, string teamId, string timeZoneInfoId, ILogger log)
        {
            try
            {
                var weekStartDate = openShift.StartDate.ApplyTimeZoneOffset(timeZoneInfoId).StartOfWeek(_teamOptions.StartDayOfWeek);
                var policy        = GetConflictRetryPolicy(_teamOptions.RetryMaxAttempts, _teamOptions.RetryIntervalSeconds);

                // as the manager has approved the request and it has been assigned successfully,
                // decrement the quantity
                openShift.Quantity--;

                // update the cache for the assignment
                await policy.ExecuteAsync(() => UpdateCachedOpenShiftsAsync(teamId, openShift, weekStartDate)).ConfigureAwait(false);

                // get the new shift created from the open shift in Teams
                var newShift = changeRequest.Requests
                               .Where(r => r.Method.Equals("POST", StringComparison.OrdinalIgnoreCase))
                               .Select(r => r.Body.ToObject <ShiftResponse>())
                               .First();

                // convert the open shift to a shift
                openShift.Quantity        = 1;
                openShift.WfmEmployeeId   = openShiftRequest.WfmSenderId;
                openShift.TeamsEmployeeId = openShiftRequest.SenderUserId;
                openShift.TeamsShiftId    = newShift.Id;
                openShift.WfmShiftId      = newWfmShiftId;

                // and add it to the week shifts cache
                await policy.ExecuteAsync(() => UpdateCachedShiftsAsync(teamId, openShift, weekStartDate)).ConfigureAwait(false);

                // finally, remove the request from cache as we have finished with it
                await _requestCacheService.DeleteRequestAsync(teamId, openShiftRequest.Id).ConfigureAwait(false);

                return(true);
            }
            catch (Exception ex)
            {
                // the employee cannot claim this shift, so log it and try the next
                log.LogOpenShiftAssignmentError(ex, openShiftRequest.WfmSenderId, openShift.WfmShiftId, teamId);
            }

            return(false);
        }
Пример #10
0
        protected override bool ValidateInput()
        {
            PageCheckManager manager = new PageCheckManager();

            manager.Add(new DateCheck(lblDateQuery, DateEdit.Text, true));
            manager.Add(new LengthCheck(lblSSEdit, txtSSEdit, 40, true));
            manager.Add(new LengthCheck(lblShiftCodeEdit, txtShiftCodeEdit, 40, true));
            manager.Add(new LengthCheck(lblCrewCodeEdit, txtCrewCodeEdit, 40, true));

            if (!manager.Check())
            {
                WebInfoPublish.Publish(this, manager.CheckMessage, this.languageComponent1);
                return(false);
            }

            BaseModelFacade baseModelFacade    = new BaseModelFacade(this.DataProvider);
            object          stepSequenceObject = baseModelFacade.GetStepSequence(FormatHelper.CleanString(this.txtSSEdit.Text.ToUpper()));

            if (stepSequenceObject == null)
            {
                WebInfoPublish.Publish(this, "$CS_STEPSEQUENCE_NOT_EXIST", this.languageComponent1);
                return(false);
            }

            ShiftModelFacade shiftModelFacade = new ShiftModelFacade(this.DataProvider);
            object           shiftObject      = shiftModelFacade.GetShift(FormatHelper.CleanString(this.txtShiftCodeEdit.Text.ToUpper()));

            if (shiftObject == null)
            {
                WebInfoPublish.Publish(this, "$Error_Shift_Not_Exist", this.languageComponent1);
                return(false);
            }

            ShiftModel shiftModel = new ShiftModel(this.DataProvider);
            object     crewObject = shiftModel.GetShiftCrew(FormatHelper.CleanString(this.txtCrewCodeEdit.Text.ToUpper()));

            if (crewObject == null)
            {
                WebInfoPublish.Publish(this, "$Error_ShiftCrew_Not_Exist", this.languageComponent1);
                return(false);
            }
            return(true);
        }
Пример #11
0
        public ShiftModel CreateShift(ShiftModel model)
        {
            using (IDbConnection connection = new MySqlConnection(GlobalConfig.CnnString(db)))
            {
                var p = new DynamicParameters();
                p.Add("@ShiftID", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);
                p.Add("@InStaffID", model.StaffID);
                p.Add("@InLoginTime", model.LoginTime);
                connection.Execute("spCreateShift", p, commandType: CommandType.StoredProcedure);


                // grabs newly created ID from database and returns it as part of the current Person Model
                // https://stackoverflow.com/questions/13151861/fetch-last-inserted-id-form-stored-procedure-in-mysql
                var id = p.Get <int?>("ShiftID");
                model.ShiftID = Convert.ToInt32(id);

                return(model);
            }
        }
Пример #12
0
        public ActionResult Edit(int id)
        {
            WFMDBDataContext db = new WFMDBDataContext();
            List <uspWFMGetSingleShiftResult> lstShift = db.uspWFMGetSingleShift(id).ToList();

            if (lstShift.Count > 0)
            {
                ShiftModel shift = new ShiftModel();
                shift.ShiftID   = lstShift[0].iShiftID;
                shift.ShiftName = lstShift[0].vShiftName;
                shift.StartTime = lstShift[0].vStartTime;
                shift.EndTime   = lstShift[0].vEndTime;
                return(View(shift));
            }
            else
            {
                return(RedirectToAction("Message", "Error", new { Error = "シフト在しません。" }));
            }
        }
        public async Task <IActionResult> CreateShift(ShiftModel model)
        {
            if (!await EmployeeExists(model.EmployeeId))
            {
                return(new NotFoundResult());
            }

            var shift = model.ToShift();

            if (await _shiftRepository.IsEmployeeAlreadyAssignedAShift(shift, model.EmployeeId))
            {
                return(new BadRequestObjectResult("A shift is already assigned to the employee."));
            }

            _shiftRepository.CreateShift(shift);
            await _shiftRepository.SaveChanges();

            return(new OkResult());
        }
Пример #14
0
        protected void drpCrewCode_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownListBuilder builder = new DropDownListBuilder(this.drpCrewCodeEdit);

                if (shiftModelFacade == null)
                {
                    shiftModelFacade = new ShiftModel(base.DataProvider);
                }

                builder.HandleGetObjectList += new BenQGuru.eMES.Web.Helper.GetObjectListDelegate(this.shiftModelFacade.GetAllShiftCrew);

                builder.Build("CrewCode", "CrewCode");
                this.drpCrewCodeEdit.Items.Insert(0, new ListItem("", ""));

                this.drpCrewCodeEdit.SelectedIndex = 0;
            }
        }
Пример #15
0
        public async Task <IEnumerable <ShiftModel> > ShiftReportAsync(DateTime from, DateTime to, string keyword, string terminal)
        {
            var        items = new List <ShiftModel>();
            SqlCommand cmd   = new SqlCommand();

            cmd.CommandText = StoredProcedure;
            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@DateFrom", from);
            cmd.Parameters.AddWithValue("@DateTo", to);
            cmd.Parameters.AddWithValue("@Keyword", keyword);
            cmd.Parameters.AddWithValue("@Terminal", terminal);
            var result = await SCObjects.ExecGetDataAsync(cmd, Properties.Settings.Default.UserConnectionString);

            if (result != null)
            {
                foreach (DataRow dr in result.Rows)
                {
                    var item = new ShiftModel
                    {
                        SRNumber          = dr["SRNumber"].ToString(),
                        Type              = dr["Type"].ToString(),
                        DateTimeIn        = dr["DateTimeIn"].ToString(),
                        DateTimeOut       = dr["DateTimeOut"].ToString(),
                        ExitCount         = int.Parse(dr["ExitCount"].ToString()),
                        GrossAmount       = dr["GrossAmount"].ToString().Length > 0 ? decimal.Parse(dr["GrossAmount"].ToString()) : 0,
                        Vatable           = dr["Vatable"].ToString().Length > 0 ? decimal.Parse(dr["Vatable"].ToString()) : 0,
                        Vat               = dr["Vat"].ToString().Length > 0 ? decimal.Parse(dr["Vat"].ToString()) : 0,
                        Discount          = dr["Discount"].ToString().Length > 0 ? decimal.Parse(dr["Discount"].ToString()) : 0,
                        AmountTendered    = dr["AmountTendered"].ToString().Length > 0 ? decimal.Parse(dr["AmountTendered"].ToString()) : 0,
                        Change            = dr["Change"].ToString().Length > 0 ? decimal.Parse(dr["Change"].ToString()) : 0,
                        ChangeFund        = dr["ChangeFund"].ToString().Length > 0 ? decimal.Parse(dr["ChangeFund"].ToString()) : 0,
                        TenderDeclaration = dr["TenderDeclaration"].ToString().Length > 0 ? decimal.Parse(dr["TenderDeclaration"].ToString()) : 0,
                        SubTotal          = dr["SubTotal"].ToString().Length > 0 ? decimal.Parse(dr["SubTotal"].ToString()) : 0,
                        Variance          = dr["Variance"].ToString().Length > 0 ? decimal.Parse(dr["Variance"].ToString()) : 0,
                        Cashier           = dr["Cashier"].ToString(),
                        Exit              = dr["Exit"].ToString(),
                    };
                    items.Add(item);
                }
            }
            return(items);
        }
Пример #16
0
        private void CreateNewShiftPatterns(ShiftModel model)
        {
            int daysInPattern = model.DaysInPattern.Value;
            //Default Start Time: 00:00:00 and EndTime: 23:59:59
            TimeSpan startTime = new TimeSpan(0, 0, 0);
            TimeSpan endTime   = new TimeSpan(23, 59, 59);

            for (int i = 0; i < daysInPattern; i++)
            {
                var shiftPattern = new ShiftPattern
                {
                    Sequence  = i + 1,
                    ShiftId   = model.Id,
                    StartTime = DateTime.Now + startTime,
                    EndTime   = DateTime.Now + endTime
                };
                this._shiftPatternRepository.Insert(shiftPattern);
            }
            this._dbContext.SaveChanges();
        }
Пример #17
0
        // GET: Shift/Edit/5
        public ActionResult Edit(long id)
        {
            var shift = service.GetShift(id);

            if (shift == null)
            {
                return(HttpNotFound());
            }
            var shiftModel = new ShiftModel
            {
                Id        = shift.Id,
                ShiftName = shift.ShiftName,
                StartTime = shift.StartTime,
                EndTime   = shift.EndTime,
                BreakTime = shift.BreakTime
            };

            ViewBag.Id = new SelectList(serviceEmployee.GetAllEmployees(), "Id", "FirstName", shift.Id);
            return(View(shiftModel));
        }
        public IHttpActionResult UpdateShift(ShiftModel shiftModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var shiftDto = Mapper.Map <ShiftDto>(shiftModel);

                _shiftAppService.Update(shiftDto, AuthHelper.GetCurrentUserId());

                return(Ok("Shift Updated"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #19
0
        public IActionResult Post(int id, [FromQuery] bool?copyAllDays, [FromBody] ShiftModel shift)
        {
            if (shift == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(new ObjectResult(ModelState));
            }

            Schedule schedule = GetSchedule(id);

            UserCanAccessOrganization(schedule.Organization.OrganizationId);

            var positions = GetAvailableSchedulePositions(schedule);

            if (copyAllDays.HasValue && copyAllDays.Value)
            {
                foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)))
                {
                    var shiftEntity = shift.Export(positions);
                    shiftEntity.Day      = day.ToString();
                    shiftEntity.Schedule = schedule;

                    _schedulerContext.Shifts.Add(shiftEntity);
                }
            }
            else
            {
                var shiftEntity = shift.Export(positions);
                shiftEntity.Schedule = schedule;

                _schedulerContext.Shifts.Add(shiftEntity);
            }

            _schedulerContext.SaveChanges();

            return(new ObjectResult(shift));
        }
Пример #20
0
        public int insert_ShiftDetails(ShiftModel objShiftModel)
        {
            try
            {
                return(Execution.ExecuteNonQuery_with_result("sp_shift", new SqlParameter[]
                {
                    new SqlParameter("@Command", "INSERT"),



                    new SqlParameter("@shiftname", objShiftModel.shiftName),
                    new SqlParameter("@starttime", objShiftModel.starttime),
                    new SqlParameter("@endtime", objShiftModel.endtime),

                    new SqlParameter("@status", 1),
                }));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task CreateShiftAsync(string teamId, ShiftModel shift)
        {
            Guard.ArgumentNotNullOrEmpty(shift.TeamsSchedulingGroupId, nameof(ShiftModel.TeamsSchedulingGroupId));
            Guard.ArgumentNotNullOrEmpty(shift.TeamsEmployeeId, nameof(ShiftModel.TeamsEmployeeId));

            var client = _clientFactory.CreateClient(_options, teamId);

            var request = new ShiftRequest
            {
                SchedulingGroupId = shift.TeamsSchedulingGroupId,
                UserId            = shift.TeamsEmployeeId,
                DraftShift        = _options.DraftShiftsEnabled ? _shiftMap.MapShift(shift) : null,
                SharedShift       = _options.DraftShiftsEnabled ? null : _shiftMap.MapShift(shift)
            };

            var response = await client.CreateShiftAsync(request, teamId);

            response.ThrowIfError();

            // update the shift with the Teams id for the shift
            shift.TeamsShiftId = ((ShiftResponse)response).Id;
        }
Пример #22
0
        public IList <ShiftMergedModel> Save([FromBody] ShiftModel helper)
        {
            List <ShiftMergedModel> shiftList = new List <ShiftMergedModel>();
            TimeSpan ts = new TimeSpan(00, 00, 01);

            foreach (var item in helper.Amounts)
            {
                for (int i = 1; i <= item.Amount; i++)
                {
                    Shifts shift = new Shifts();
                    shift.OrganizationId = helper.OrganizationId;
                    shift.EmployeeId     = null;
                    shift.positionId     = item.Id;
                    shift.ShiftDate      = helper.ShiftDate + ts;
                    shift.CreatedAt      = DateTime.Now;

                    var insertedShift = GetShift(shift);
                    shiftList.Add(insertedShift);
                }
            }
            return(shiftList.ToArray());
        }
Пример #23
0
        public virtual ShiftModel PrepareShiftModel(ShiftModel model, Shift shift, bool excludeProperties = false)
        {
            //Action<DoctorLocalizedModel, int> localizedModelConfiguration = null;


            if (shift != null)
            {
                //fill in model values from the entity
                model = model ?? shift.ToModel <ShiftModel>();
            }

            //set default values for the new model
            if (shift == null)
            {
                model.Active       = true;
                model.Deleted      = false;
                model.CreatedBy    = _workContext.CurrentCustomer.Id;
                model.CreatedOnUtc = DateTime.UtcNow;
            }

            return(model);
        }
Пример #24
0
        public async Task UpdateOpenShiftAsync(string teamId, ShiftModel openShift)
        {
            Guard.ArgumentNotNullOrEmpty(openShift.TeamsShiftId, nameof(ShiftModel.TeamsShiftId));
            Guard.ArgumentNotNullOrEmpty(openShift.TeamsSchedulingGroupId, nameof(ShiftModel.TeamsSchedulingGroupId));

            var client = _clientFactory.CreateClient(_options, teamId);

            // get the existing open shift from Teams
            var openShiftResponse = await client.GetOpenShiftAsync(teamId, openShift.TeamsShiftId).ConfigureAwait(false);

            openShiftResponse.SchedulingGroupId = openShift.TeamsSchedulingGroupId;
            if (_options.DraftShiftsEnabled)
            {
                openShiftResponse.DraftOpenShift = _shiftMap.MapOpenShift(openShift);
            }
            else
            {
                openShiftResponse.SharedOpenShift = _shiftMap.MapOpenShift(openShift);
            }

            await client.ReplaceOpenShiftAsync(openShiftResponse, string.Empty, teamId, openShiftResponse.Id).ConfigureAwait(false);
        }
Пример #25
0
        public HttpResponseMessage createEmployee([FromBody] ShiftModel objShiftModel)
        {
            if (objShiftModel.token == null)
            {
                //token from user
                var token = objShiftModel.token;
                //checking Token
                var result = Authtoken.checkToken(token);
                if (result == true)
                {
                    var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK,
                                                                      new ResponseModel()
                    {
                        message = "no token", statuscode = Convert.ToInt16(HttpStatusCode.NoContent)
                    });
                    return(resp);
                }

                else
                {
                    var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK, new ResponseModel()
                    {
                        message = "UnAuthorized", statuscode = Convert.ToInt16(HttpStatusCode.NoContent)
                    });
                    return(resp);
                }
            }
            else
            {
                objshiftDL.insert_ShiftDetails(objShiftModel);
                var resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK,
                                                                  new ResponseModel()
                {
                    message = "Shift created sucessfully", statuscode = Convert.ToInt16(HttpStatusCode.OK)
                });
                return(resp);
            }
        }
        public ActionResult EditShift(String id)
        // public ActionResult AddEditShift(String id)
        {
            ShiftModel mod = new ShiftModel();

            List <Store> accounts = (from data in db.Stores
                                     select data).ToList();

            Store objcountry = new Store();

            objcountry.storeName = "Select";
            objcountry.storeID   = 0;
            accounts.Insert(0, objcountry);
            mod.Stores = accounts.Select(a => new SelectListItem
            {
                Text  = a.storeName,
                Value = a.storeID.ToString()
            });



            Shift objshift;
            int   _hdnshiftId = Convert.ToInt32(id);

            if (_hdnshiftId > 0)
            {
                objshift            = db.Shifts.Where(o => o.shfitID == _hdnshiftId).SingleOrDefault();
                mod.startTime       = Convert.ToDateTime(objshift.startTime).ToShortTimeString();
                mod.endTime         = Convert.ToDateTime(objshift.endTime).ToShortTimeString();
                mod.SelectedStoreId = Convert.ToInt32(objshift.storeID);
                mod.editShiftId     = Convert.ToInt32(id);

                mod.shfitID   = _hdnshiftId;
                mod.shiftCode = objshift.shiftCode;
                mod.active    = Convert.ToBoolean(objshift.active);
            }
            return(View(mod));
        }
Пример #27
0
        public async Task CreateOpenShiftAsync(string teamId, ShiftModel openShift)
        {
            Guard.ArgumentNotNullOrEmpty(openShift.TeamsSchedulingGroupId, nameof(ShiftModel.TeamsSchedulingGroupId));

            var client = _clientFactory.CreateClient(_options, teamId);

            // map the shift to a Teams ShiftItem
            var openShiftItem = _shiftMap.MapOpenShift(openShift);

            var request = new OpenShiftRequest
            {
                SchedulingGroupId = openShift.TeamsSchedulingGroupId,
                DraftOpenShift    = _options.DraftShiftsEnabled ? openShiftItem : null,
                SharedOpenShift   = _options.DraftShiftsEnabled ? null : openShiftItem
            };

            var response = await client.CreateOpenShiftAsync(request, teamId).ConfigureAwait(false);

            response.ThrowIfError();

            // update the shift with the Teams id for the shift
            openShift.TeamsShiftId = ((OpenShiftResponse)response).Id;
        }
Пример #28
0
        public ActionResult ShiftMasterAddEdit(int Id)
        {
            ShiftModel Shift = new ShiftModel();

            try
            {
                if (Id > 0)
                {
                    DataTable dt   = new DataTable();
                    string    SQRY = "EXEC USP_Get_ShiftDetail_Edit '" + Id + "'";
                    dt = DBUtilities.GetDTResponse(SQRY);
                    if (dt != null)
                    {
                        List <ShiftModel> ShiftList = new List <ShiftModel>();
                        ShiftList = DataRowToObject.CreateListFromTable <ShiftModel>(dt);
                        Shift     = ShiftList.Where(c => c.Id == Id).FirstOrDefault();
                    }
                }
            }
            catch (Exception ex) { }

            return(View("ShiftMasterAddEdit", Shift));
        }
Пример #29
0
        public async Task <ShiftModel> AddAsync(ShiftModel model, int clientId, int userId)
        {
            if (!await _permissionManager.HasPermission(clientId, userId, Permission.CanAddShift))
            {
                throw new Exception("User has not permission to perform this operation");
            }

            if (model == null)
            {
                throw new ArgumentNullException();
            }

            var shift = _shiftMapper.ConvertToDataModel(model);

            shift.CreatedOn = DateTime.UtcNow;
            shift.UpdatedOn = DateTime.UtcNow;
            shift.CreatedBy = userId;
            shift.ClientId  = clientId;
            shift.IsActive  = true;

            shift = await _shiftRepository.AddAsync(shift);

            return(_shiftMapper.ConvertToModel(shift));
        }
Пример #30
0
        public IActionResult Put(int id, [FromBody] ShiftModel shift)
        {
            if (shift == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(new ObjectResult(ModelState));
            }

            var shiftEntity = _schedulerContext.Shifts
                              .Include(s => s.Schedule)
                              .Include(s => s.Schedule.Organization)
                              .Single(o => o.ShiftId == id);

            UserCanAccessOrganization(shiftEntity.Schedule.Organization.OrganizationId);

            shift.Export(shiftEntity, GetAvailableSchedulePositions(shiftEntity.Schedule));
            _schedulerContext.SaveChanges();

            return(new ObjectResult(shift));
        }