public JsonResult Post([FromBody] JObject jObject) { var response = new MessageResponseViewModel(); response.Success = false; response.Message = "Message is not sent!"; var token = jObject["Token"].ToString(); var roomId = Convert.ToInt32(jObject["RoomId"].ToString()); var userId = Convert.ToInt32(jObject["UserId"].ToString()); var text = jObject["Text"].ToString(); var email = repoUser.GetEmailById(userId); if (token.Equals(NETCore.Encrypt.EncryptProvider.Sha512(email))) { var message = new Message(); message.UserId = userId; message.RoomId = roomId; message.Text = text; repoMessage.Insert(message); repoMessage.Save(); response.Success = true; response.Message = "Message is sent!"; repoRoom.ChangeTurnAfterPost(roomId); repoRoom.IncrementPosts(roomId); } return(new JsonResult(response)); }
/// <summary> /// Retrieval external pre-product. /// </summary> /// <param name="parameters"></param> /// <returns></returns> public async Task <ActionResult> Retrieval(ExternalPreProductViewModel parameters) { try { if (parameters == null) { parameters = new ExternalPreProductViewModel(); TryValidateModel(parameters); } if (!ModelState.IsValid) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } // Find the conveyor from terminal no. var terminalNo = _identityService.FindTerminalNo(HttpContext.User.Identity); await _retrievalOfExternalProductDomain.RetrievalExternalPreProductAsync(terminalNo, parameters.F41_KndCmdNo, parameters.F41_PreProductCode, parameters.F41_PrePdtLotNo, parameters.Line); var httpMessageResponse = new MessageResponseViewModel(); httpMessageResponse.HttpStatusCode = HttpStatusCode.OK; return(Json(httpMessageResponse)); } catch (Exception exception) { var httpMessageResponse = new MessageResponseViewModel(); httpMessageResponse.HttpStatusCode = HttpStatusCode.InternalServerError; httpMessageResponse.Message = exception.Message; return(Json(httpMessageResponse)); } }
public ActionResult IndexC1(RequestRestoreMaterialViewModel parameters) { if (parameters == null) { parameters = new RequestRestoreMaterialViewModel(); TryValidateModel(parameters); } if (!ModelState.IsValid) { var httpResponseViewModel = new MessageResponseViewModel(); httpResponseViewModel.HttpStatusCode = HttpStatusCode.BadRequest; httpResponseViewModel.Message = "Invalid parameters submitted to service"; return(Json(httpResponseViewModel)); } var restoreMaterialViewModel = new RestoreMaterialViewModel(); restoreMaterialViewModel.MaterialCode = parameters.MaterialCode; restoreMaterialViewModel.MaterialDsp = parameters.MaterialDsp; restoreMaterialViewModel.ShelfNo = parameters.ShelfNo; restoreMaterialViewModel.PalletNo = parameters.PalletNo; //var materialShelfStocks = _stockTakingOfMaterialDomain.GetMaterialShelfStocks(model.ShelfNo, model.MaterialCode); var items = _stockTakingOfMaterialDomain.GetMaterialShelfStocks(parameters.ShelfNo, parameters.MaterialCode); var materials = new List <FinalStockTakingMaterialItem>(); foreach (var item in items) { var result = Math.Abs(item.F33_Amount / item.F01_PackingUnit - 1); var material = new FinalStockTakingMaterialItem(); if (result < 0.01) { material.PackQuantity = 1; material.Fraction = 0.00; } else { material.PackQuantity = Convert.ToInt32(item.F33_Amount / item.F01_PackingUnit); material.Fraction = item.F33_Amount - item.F01_PackingUnit * Convert.ToDouble(item.F33_Amount / item.F01_PackingUnit); } material.MaterialLotNo = item.F33_MaterialLotNo; material.PackUnit = item.F01_PackingUnit; material.Total = item.F33_Amount; restoreMaterialViewModel.GrandTotal += item.F33_Amount; materials.Add(material); } restoreMaterialViewModel.Materials = materials.ToArray(); return(View(restoreMaterialViewModel)); }
public async Task <ActionResult> RetrievePallets(RetrieveOfMaterialViewModel parameters) { try { if (parameters == null) { parameters = new RetrieveOfMaterialViewModel(); TryValidateModel(parameters); } if (!ModelState.IsValid) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } // Initiate message response. var messageResponse = new MessageResponseViewModel(); // Find current terminal no. var terminalNo = _identityService.FindTerminalNo(HttpContext.User.Identity); // Check the conveyor code. if (!_storageOfWarehousePalletDomain.CheckedRecordInTM05(terminalNo)) { messageResponse.HttpStatusCode = HttpStatusCode.NotFound; messageResponse.Message = HttpMessages.InvalidConveyorStatus; return(Json(messageResponse)); } // Find device. if (!_restorageOfMaterialDomain.IsValidDevice()) { messageResponse.HttpStatusCode = HttpStatusCode.NotFound; messageResponse.Message = HttpMessages.InvalidDeviceAvailability; return(Json(messageResponse)); } // Retrieve pallets. await _retrieveOfMaterialDomain.RetrieveMaterial(parameters.MaterialCode.Trim(), parameters.RequestedRetrievalQuantity, terminalNo); messageResponse.HttpStatusCode = HttpStatusCode.OK; return(Json(messageResponse)); } catch (Exception exception) { _log.Error(exception.Message, exception); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }
public override void OnException(ExceptionContext context) { _logger.LogError(context.Exception, string.Empty); context.HttpContext.Response.ContentType = "application/json"; var response = new MessageResponseViewModel(); if (context.Exception is NotFoundException) { response.Title = "Warning"; response.Status = (int)HttpStatusCode.NotFound; response.Data = context.Exception.Message; context.HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound; } if (context.Exception is BusinessException) { response.Title = "Error"; response.Status = (int)(HttpStatusCode)422; response.Data = context.Exception; context.HttpContext.Response.StatusCode = (int)(HttpStatusCode)422; } if (context.Exception is ValidationException) { var errorValues = ((ValidationException)context.Exception).Failures.Values; var message = ""; foreach (var error in errorValues) { message += "- " + error[0]; } response.Title = "Warning"; response.Status = (int)HttpStatusCode.BadRequest; response.Data = $"Erro de validação: {message}"; context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; } context.Result = new JsonResult( new { response.Title, response.Status, response.Data }); }
public async Task <ActionResult> Restorage(RestorageProductViewModel restorageProductsList) { var messageResponseViewModel = new MessageResponseViewModel(); try { if (restorageProductsList == null) { restorageProductsList = new RestorageProductViewModel(); TryValidateModel(restorageProductsList); } if (!ModelState.IsValid) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } // Find terminal no. var terminalNo = _identityService.FindTerminalNo(HttpContext.User.Identity); await _stockTakingOfProductDomain.RestoreProductsAsync(terminalNo, restorageProductsList.PalletNo, restorageProductsList.Items, restorageProductsList.Row, restorageProductsList.Bay, restorageProductsList.Level); messageResponseViewModel.HttpStatusCode = HttpStatusCode.OK; messageResponseViewModel.Message = ""; return(Json(messageResponseViewModel)); } catch (Exception exception) { messageResponseViewModel.HttpStatusCode = HttpStatusCode.InternalServerError; messageResponseViewModel.Message = exception.Message; return(Json(messageResponseViewModel)); } }