public async Task <ActionResult> Add(Request model) { if (model.Descripcion != null) { if (_clientServece.GetByIdUser(model.ApplicationUserId).ProfileUpdated) { if (!_requestService.Exist(model)) { if (await _requestService.Add(model)) { TempData["request"] = "Solicitud enviada correctamente"; TempData["icon"] = "success"; } else { TempData["request"] = "Upss!, algo ha ocurrido no se ha enviado la solicitud"; TempData["icon"] = "error"; } } else { TempData["request"] = "Existe una solicitud con ese nombre,Porfavor tome un nombre diferente"; TempData["icon"] = "error"; } } else { TempData["request"] = "Lo sentimos!, Para poder hacer solicitudes debe completar su perfil"; TempData["icon"] = "error"; } } return(RedirectToAction("MyRequests", new { id = User.Identity.GetUserId() })); }
public void OnResultExecuted(ResultExecutedContext context) { List <Request> requests = new List <Request>(); Request request = new Request(context.Result.ToString(), context.RouteData.ToString(), context.HttpContext.ToString()); requestService.Add(request); }
public void SendHoldingRequest(SendHoldingRequestItemVo holdingRequestItem) { using (var tran = new TransactionScope()) { var holdingRequest = GetById(holdingRequestItem.HoldingRequestSelectedId); var request = new Request() { RequestNo = _staticValueService.GetNewRequestNumber(), LocationFrom = holdingRequest.LocationFrom, LocationTo = holdingRequest.LocationTo, StartTime = holdingRequest.StartTime.GetValueOrDefault(), EndTime = holdingRequest.EndTime.GetValueOrDefault(), SendingTime = holdingRequestItem.IsStat ? DateTime.UtcNow : holdingRequestItem.SendingTime, IsStat = holdingRequestItem.IsStat, Status = (int)StatusRequest.NotSent, CourierId = holdingRequestItem.CourierId, Description = holdingRequest.Description, ExpiredTime = holdingRequestItem.ExpiredTime, SaveSystemEvent = false }; _requestService.Add(request); _holdingRequestRepository.Delete(holdingRequest); _holdingRequestRepository.Commit(); _systemEventRepository.Add(EventMessage.RequestCreated, new Dictionary <EventMessageParam, string>() { { EventMessageParam.Request, request.RequestNo }, { EventMessageParam.Courier, _courierRepository.GetById(holdingRequestItem.CourierId.GetValueOrDefault()).User.UserName } }); tran.Complete(); } }
public async Task <IActionResult> Submit(RequestDto dto) { var result = await _requestService.Add(dto); if (result) { return(Ok("Yêu cầu của bạn đang chờ xét duyệt")); } else { return(Ok("Lỗi chưa xác định")); } }
public async Task <IActionResult> Create([FromBody] Request oUser) { try { await _requestService.Add(oUser); return(new OkObjectResult(oUser)); } catch (Exception ex) { return(StatusCode(500, "Internal server error" + ex.Message)); } }
public async Task <IActionResult> CreateRequest(ServiceRequestEditModel model) { if (ModelState.IsValid) { string output = ""; foreach (DaysOfWeek p in model.Days) { if (p.IsChecked == true) { output += p.name + ","; } } string name = User.Identity.Name; var lp = await userManager.FindByNameAsync(name); string Id = await userManager.GetUserIdAsync(lp); var kp = new ServiceRequest() { Customer = lp, Service = ServiceImp.Get(model.ServiceID), ServiceType = ServiceTypeImp.Get(model.ServiceTypeID), SheduleDate = DateTime.Parse(model.GetDate), DaysOfWork = output, Phone = model.Phone, Address = model.Address, City = model.City, Status = "Not Approved", RequestName = GetName(name) + "/" + model.SheduleDate.ToString() }; ServiceRequestImp.Add(kp); ServiceRequestImp.Commit(); ModelState.Clear(); HttpContext.Session.SetString("RequestSuccess", "Cleaning Request Successful"); return(RedirectToAction("CreateRequest")); } ServiceRequestEditModel po = new ServiceRequestEditModel() { Days = GetDays(), Service = new SelectList(ServiceImp.GetAll(), "Id", "ServiceName"), ServiceType = new SelectList(ServiceTypeImp.GetAll(), "Id", "ServiceType") }; return(View(po)); }
private void btnOk_Click(object sender, EventArgs e) { List <ProductRequest> productRequests = new List <ProductRequest>(); foreach (DataGridViewRow item in dtgvProductsFound.Rows) { try { int quantity = int.Parse(item.Cells["quantity"].Value.ToString()); if (quantity > 0) { var product = _productService.GetById(int.Parse(item.Cells["id"].Value.ToString())); productRequests.Add(new ProductRequest() { Product = product, Quantity = quantity }); } } catch (Exception) { MessageBox.Show("campo quantidade aceita apenas numeros"); return; } } if (productRequests.Count > 0) { Request request = _request != null ? _request : new Request(); request.ProductsRequest = productRequests; if (_request != null) { _requestService.Update(request); } else { request.Status = Domain.Object_Values.Status.Aberto; request.DateRequest = DateTime.Now; request.AcceptanceDate = null; request.DeliveryDate = null; request.User = _user; _requestService.Add(request); } } this.Close(); }
public IHttpActionResult AddRequest([FromBody] RequestDto dto) { if (dto == null) { return(BadRequest()); } var result = _requestService.Add(dto); if (result == null) { return(BadRequest()); } return(Ok(result)); }
public ActionResult Index(RequestViewModel request) { UserSessionModel session = (UserSessionModel)Session[Constants.USER_SESSION]; try { if (ModelState.IsValid) { using (TransactionScope tran = new TransactionScope()) { Request res = _requestService.Add(new Request { Content = request.Content, UserId = session.UserId, RequestDate = DateTime.Now, Status = RequestStatus.Sending, DepartmentId = request.DepartmentId }); if (request.AttachName != null) { foreach (string item in request.AttachName) { _attachService.Add(new Attach { Path = item, DateUpload = DateTime.Now, RequestId = res.RequestId }); } } TempData[V2] = V1; tran.Complete(); } } } catch (Exception) { TempData[V2] = V; } return(Redirect("/Student/Dashboards")); }
public IActionResult AddRequest(Request request) { _requestService.Add(request); return(Ok()); }
public ActionResult <RequestDetailViewModel> PostRequestDetail(RequestDetailViewModel requestDetail) { _requestService.Add(requestDetail); _requestService.Save(); return(CreatedAtAction("GetRequestDetail", new { id = requestDetail.Id }, requestDetail)); }
public void Add(RequestViewModel requestViewModel) { var requestEntity = _mapper.Map <RequestViewModel, RequestEntity>(requestViewModel); _requestService.Add(requestEntity); }
public async Task <HttpResponseMessage> Create(HttpRequestMessage request, RequestViewModel requestViewModel) { return(await CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } var dateNow = DateTime.Now.Date; if (requestViewModel.StartDate < dateNow) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_CREATE_REQUEST_IN_PAST_NOT_MSG); } else { requestViewModel.AppUser = new Models.AppUserViewModel(); requestViewModel.CreatedDate = DateTime.Now; requestViewModel.UserId = AppUserManager.FindByNameAsync(User.Identity.Name).Result.Id; requestViewModel.AppUser.GroupId = AppUserManager.FindByNameAsync(User.Identity.Name).Result.GroupId ?? 0; requestViewModel.Status = true; //requestViewModel.ChangeStatusById = __groupService.GetGroupLeadIdByGroup(requestViewModel.AppUser.GroupId.Value); Request newRequest = new Request(); newRequest.UpdateRequest(requestViewModel); //Check Request Day Off var model = _requestService.GetAllRequest(newRequest); if (model == 0) { if (_requestService.checkUnitEntitleday(newRequest)) { if (_requestService.Add(newRequest)) { var responseData = Mapper.Map <Request, RequestViewModel>(newRequest); var group = __groupService.GetGroupById(requestViewModel.AppUser.GroupId.ToString()); responseData.GroupName = group.Name; var dataDelegation = _configDelegationService.GetDelegationByUserId(newRequest.UserId); if (dataDelegation.StartDate <= newRequest.CreatedDate.Value.Date && dataDelegation.EndDate >= newRequest.CreatedDate.Value.Date) { responseData.CheckConfigDelegateDefault = true; responseData.AssignConfigDelegate = dataDelegation.AssignTo; _configDelegationService.ChangeStatusAfterAddRequest(dataDelegation.AssignTo, newRequest); } else { if (newRequest.CreatedDate != null) { if (group.DelegateId != null && group.StartDate <= newRequest.CreatedDate.Value.Date && group.EndDate >= newRequest.CreatedDate.Value.Date) { responseData.CheckGroupDelegateDefault = true; responseData.AssignGroupDelegate = group.DelegateId; _requestService.CheckDelegateDefault(requestViewModel.AppUser.GroupId.ToString(), newRequest.ID, newRequest.ChangeStatusById); } } } return request.CreateResponse(HttpStatusCode.Created, responseData); } } else { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_ENTITLEDAY); } return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_CREATE_REQUEST_NOT_MSG); } if (model == 1) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME); } if (model == 2) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME_MORNING); } if (model == 3) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME_AFTERNOON); } if (model == 4) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME_LATECOMING); } if (model == 5) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME_EARLYLEAVING); } if (model == 6) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME); } if (model == 7) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_MORNING); } if (model == 8) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_MORNING_LATECOMING); } if (model == 9) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME); } if (model == 10) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_AFTERNOONLEAVE); } if (model == 11) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_AFTERNOONLEAVE_EARLYLEAVING); } if (model == 12) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME); } if (model == 13) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_MORNING_LATECOMING); } if (model == 14) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_LATECOMING_EARLYLEAVING); } if (model == 15) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_FULLTIME); } if (model == 16) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_EARLYLEAVING_AFTERNOONLEAVE); } if (model == 17) { return request.CreateResponse(HttpStatusCode.BadRequest, MessageSystem.ERROR_REQUEST_EARLYLEAVING); } } return response; })); }
public TableDataRecord Create([FromBody] IDictionary <string, object> properties) { return(_requestService.Add(null, Root, null, properties)); }