public async Task <BookLogForEmailModel> BookLog_Set(BookLogForCreateModel model) { using (var con = GetDbConnection(_options.Value.DevHubDBConn)) { var result = await con.QueryAsync <BookLogForEmailModel>("dbo.DevHub_BookLog_Set", new { @iIntBookingID = model.BookingID, @iIntBookingTypeID = model.BookingTypeID, @iIntAmenityID = model.AmenityID, @iIntFrequencyID = model.FrequencyID, @iDtDateTimeOfArrival = model.DateTimeOfArrival, @iDtDateTimeOfDeparture = model.DateTimeOfDeparture, @iStrRemarks = model.Remarks, @iStrFirstName = model.FirstName, @iStrMiddleName = model.MiddleName, @iStrLastName = model.LastName, @iStrEmail = model.Email, @iStrContactNumber = model.ContactNumber, @iStrProfession = model.Profession, @iStrUserName = model.UserName, @iBoolbookStatus = model.bookStatus, @iIntRateID = model.RateID }, commandType : CommandType.StoredProcedure); return(result.FirstOrDefault()); } }
public async Task <IActionResult> BookLogCreate([FromBody] BookLogForCreateModel model) { // validate request if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var uri = HttpContext.Request.Host.Value; if (model.BookingTypeID == 3) { model.UserName = "******"; } else { model.UserName = _baseUserName; } var result = await _service.BookLog_Set(model, _baseUri); if (result == null) { return(BadRequest()); } return(Ok(result)); }
public async Task <BookLogForCreateUpdateReturnModel> BookLog_Set(BookLogForCreateModel model, string uri) { var result = await _repo.BookLog_Set(model); var emailRecipients = await _emails.EmailRecipientList_Get(); if (result != null) { if (model.BookingTypeID == 3) { if (model.AmenityID == 3 || model.AmenityID == 4) { foreach (var recipient in emailRecipients) { result.Recipient = recipient; await _send.SendEmail(_send.BookLogForEmailParam(result, "Add-Admin-Booking-Template", uri, true)); } await _send.SendEmail(_send.BookLogForEmailParam(result, "Confirm-Booking-Conference-Template", uri, false)); } else { foreach (var recipient in emailRecipients) { result.Recipient = recipient; await _send.SendEmail(_send.BookLogForEmailParam(result, "Add-Admin-Booking-Template", uri, true)); } await _send.SendEmail(_send.BookLogForEmailParam(result, "Confirm-Booking-Template", uri, false)); } } } var modelForReturn = _mapper.Map <BookLogForCreateUpdateReturnModel>(result); return(modelForReturn); }