public async Task <EmailDataArgs> UpdateSlotPeriodAsync(UpdateSlotPeriodRequestArgs request) { var data = await DbContext.ExecuteReaderAsync(DataConstants.PR_PLAN_CHANGE_SLOT, CommandType.StoredProcedure, args => { args.Add("@SlotID", request.SlotID); args.Add("@PlannedDate", request.PlannedDate); args.Add("@ExpectedDate", request.ExpectedDate); }, reader => new EmailDataArgs { ReservationNumber = reader.Get <string>(0), SlotName = reader.Get <string>(1), PeriodName = reader.Get <string>(2), ChangedPeriodName = reader.Get <string>(3), PlannedDate = reader.Get <DateTime>(4), ChangedPlannedDate = reader.Get <DateTime>(5), RequestUser = reader.Get <string>(6), ExpectedDate = reader.Get <DateTime>(7), ChangedExpectedDate = reader.Get <DateTime>(8), ExpectedPeriodName = reader.Get <string>(9), ChangedExpectedPeriodName = reader.Get <string>(10), Action = "Changed" }); return(data.FirstOrDefault()); //send email //return await SendMail(data.FirstOrDefault()); }
public async Task <SlotApprovalResult> UpdateSlotPeriodAsync(UpdateSlotPeriodRequestArgs request) { //var res = new SlotApprovalResult //{ // Message = "Slot updated successfully.", // Success = true //}; //EmailDataArgs item = null; //if(request.PlannedDate != null && request.ExpectedDate != null) // item = await _repository.UpdateSlotPeriodAsync(request); //if(item !=null) // return await SendEmailAsync(item); //return res; var res = new SlotApprovalResult { Message = "Slot updated successfully.", Success = true }; EmailDataArgs item = null; SlotApprovalResult resp1 = new SlotApprovalResult(); var slotData = await _repository.GetSlotDataAsync(request.SlotID); if (slotData != null) { if (request.PlannedDate != null && request.ExpectedDate != null) { if (request.PlannedDate.Value.ToShortDateString() != slotData.PlannedDate.ToShortDateString() || request.ExpectedDate.Value.ToShortDateString() != slotData.ExpectedDate.ToShortDateString()) { item = await _repository.UpdateSlotPeriodAsync(request); } } if ((request.NrOfPlates > 0) && (request.NrOfTests != slotData.NrOfTests || request.NrOfPlates != slotData.NrOfPlates)) { resp1 = await EditSlotAsync(new EditSlotRequestArgs { Forced = request.Forced, NrOfPlates = request.NrOfPlates, NrOfTests = request.NrOfTests, SlotID = request.SlotID }); } } if (item != null) { return(await SendEmailAsync(item)); } if (!resp1.Success) { res.Message = resp1.Message; res.Success = false; } ; return(res); }
public async Task <IHttpActionResult> UpdateSlotPeriod([FromBody] UpdateSlotPeriodRequestArgs args) { //alllow overrides for this role only args.AllowOverride = User.IsInRole(AppRoles.HANDLE_LAB_CAPACITY); var data = await slotService.UpdateSlotPeriodAsync(args); return(Ok(data)); }