public async Task <ActionResult> CustomerSetExecutorForIndent(UserActivityViewModel activityModel) { var clientId = Session["Id"]; if (clientId == null) { return(RedirectToAction("Registration", "Customer")); } int customerId = Convert.ToInt32(clientId); string customerName = Session["Name"].ToString(); IndentDTO indentDTO = new IndentDTO() { IndentId = activityModel.IndentId }; await _userActivityService.SaveExecutorForIndent(indentDTO, activityModel.UserOpponentId); string cacheKey = "show-indent-" + activityModel.IndentId.ToString(); IndentDTO cachedIndent = HttpContext.Cache[cacheKey] as IndentDTO; if (cachedIndent != null) { HttpContext.Cache.Remove(cacheKey); } NotificationDTO notificationDTO = GenerateNotification(activityModel, Role.Executor, "Сandidature confirmed"); notificationDTO.FromId = customerId; notificationDTO.FromName = customerName; await _userActivityService.SaveNotification(notificationDTO); return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); }
public ActionResult BindShelfAvailabilityDetails(IndentDTO objavailablequantity) { string lstDirectIndentGrid = mmsTransactions.BindShelfAvailabilityDetails(objavailablequantity); return(new JsonResult { Data = lstDirectIndentGrid, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult ShowDirectIndentGridDetails(IndentDTO lstobjproductname) { List <IndentDTO> lstDirectIndentGrid = mmsTransactions.ShowDirectIndentGridDetails(lstobjproductname); return(new JsonResult { Data = lstDirectIndentGrid, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public async Task SaveExecutorForIndent(IndentDTO indentDTO, int executorId) { Indent indent = _mapper.Map <Indent>(indentDTO); indent.Executor = new Executor() { ExecutorId = executorId }; await _database.Indents.SetExecutorId(indent); }
public JsonResult IndentIssueDetailsBind(IndentDTO objindentissue) { List <IndentDTO> lstindentissue = mmsTransactions.IssueDetailsBind(objindentissue); List <IndentDTO> lstproductstores = mmsTransactions.IssueProductStores(objindentissue); List <IndentDTO> lstproductshelfstores = mmsTransactions.IssueProductShelfsStores(objindentissue); var data = new { IndentDetails = lstindentissue, storagedetails = lstproductstores, productshelfstores = lstproductshelfstores }; return(new JsonResult { Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult SaveIndentIssueDetails(IndentDTO ID, List <IndentDTO> ID2, string conversionamount) { int userid = Convert.ToInt32(Session["UserId"]); ID.userid = userid.ToString(); ID.numissueconvertionqty = conversionamount; int Indentcount = mmsTransactions.SaveIndentIssueDetails(ID, ID2); return(new JsonResult { Data = Indentcount, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public async Task <ActionResult> SaveExecutorRecallForCustomer(UserActivityViewModel activityModel) { var clientId = Session["Id"]; if (clientId == null) { return(RedirectToAction("Registration", "Executor")); } if (activityModel.Mark == null) { TempData["ErrorMessage"] = "Вы не оценили действия заказчика!"; return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); } int executorId = Convert.ToInt32(clientId); string executorName = Session["Name"].ToString(); RecallDTO recallDTO = new RecallDTO() { RecallId = activityModel.IndentId, ExecutorCommentForCustomer = activityModel.Comment, ExecutorMarkForCustomer = activityModel.Mark }; await _userActivityService.SaveExecutorRecallForCustomer(recallDTO); string cacheKeyForIndent = "show-indent-" + activityModel.IndentId.ToString(); IndentDTO cachedIndent = HttpContext.Cache[cacheKeyForIndent] as IndentDTO; if (cachedIndent != null) { HttpContext.Cache.Remove(cacheKeyForIndent); } string cacheKeyForCustomer = "show-customer-" + activityModel.UserOpponentId.ToString(); CustomerDTO cachedCustomer = HttpContext.Cache[cacheKeyForCustomer] as CustomerDTO; if (cachedCustomer != null) { HttpContext.Cache.Remove(cacheKeyForCustomer); } NotificationDTO notificationDTO = GenerateNotification(activityModel, Role.Customer, "Recall"); notificationDTO.FromId = executorId; notificationDTO.FromName = executorName; await _userActivityService.SaveNotification(notificationDTO); return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); }
public IndentDTO Get(int id) { Indent indent = _database.Indents.GetById(id); if (indent == null) { throw new ValidationException("Заказ не найден!", ""); } IndentDTO indentDTO = _mapper.Map <IndentDTO>(indent); return(indentDTO); }
public async Task <int?> Create(IndentDTO indentDTO) { Indent indent = _mapper.Map <Indent>(indentDTO); int?indentId = await _database.Indents.Create(indent); if (indentId == null) { throw new ValidationException("Были введены некорректные данные, попробуйте снова!", ""); } return(indentId); }
public ActionResult SaveDirectIndentIssueDetails(string vchrequestedby, string ApprovalBy, string IssuedBy, string IND2, string deptname) { JavaScriptSerializer serializer = new JavaScriptSerializer(); List <IndentDTO> ID2 = serializer.Deserialize <List <IndentDTO> >(IND2); IndentDTO ID = new IndentDTO(); ID.ApprovalBy = ApprovalBy; ID.IssuedBy = IssuedBy; ID.vchrequestedby = vchrequestedby; int userid = Convert.ToInt32(Session["UserId"]); ID.userid = userid.ToString(); ID.DeparmentName = deptname; int Indentcount = mmsTransactions.SaveDirectIndentIssueDetails(ID, ID2); return(new JsonResult { Data = Indentcount, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public async Task <ActionResult> SaveIndent(IndentViewModel indentViewModel, string indentCategory, string indentPrice) { var clientId = Session["Id"]; if (clientId == null) { return(RedirectToAction("Registration", "Customer")); } int customerId = Convert.ToInt32(clientId); string imgSrc = null; string fileMimeType; if (indentViewModel.IndentDate.Year < DateTime.Now.Year || (indentViewModel.IndentDate.Year == DateTime.Now.Year && indentViewModel.IndentDate.Month < DateTime.Now.Month) || (indentViewModel.IndentDate.Year == DateTime.Now.Year && indentViewModel.IndentDate.Month == DateTime.Now.Month && indentViewModel.IndentDate.Day < DateTime.Now.Day)) { TempData["ErrorMessage"] = "Были введены некорректные данные, попробуйте снова!"; return(RedirectToAction("CreateIndent", "Customer")); } if (Request.Files.Count > 0) { HttpPostedFileBase file = Request.Files[0]; fileMimeType = file.ContentType; if (!fileMimeType.Equals("application/octet-stream")) { if (fileMimeType.Equals("image/jpeg")) { imgSrc = Path.Combine(Server.MapPath("~/Content/Indent"), "indentId.jpeg"); if (System.IO.File.Exists(imgSrc)) { System.IO.File.Delete(imgSrc); } } else { TempData["ErrorMessage"] = "Загружать фотографии разрешается только в jpeg формате!"; return(RedirectToAction("CreateIndent", "Customer")); } } } double?priceOfIndent; Regex patternForPrice = new Regex(@"^[0-9]*\,?[0-9]+\s?$", RegexOptions.IgnoreCase); if (indentPrice == null) { priceOfIndent = null; } else if (patternForPrice.IsMatch(indentPrice.Trim())) { try { priceOfIndent = Convert.ToDouble(indentPrice.Trim()); } catch (Exception e) { TempData["ErrorMessage"] = "Были введены некорректные данные, попробуйте снова!"; return(RedirectToAction("CreateIndent", "Customer")); } } else { TempData["ErrorMessage"] = "Были введены некорректные данные, попробуйте снова!"; return(RedirectToAction("CreateIndent", "Customer")); } if (indentViewModel.Title == null || indentViewModel.City == null || indentViewModel.IndentDescription == null) { TempData["ErrorMessage"] = "Были введены некорректные данные, попробуйте снова!"; return(RedirectToAction("CreateIndent", "Customer")); } if (Session["Language"] != null) { string lan = Session["Language"].ToString(); if (lan == "en") { indentViewModel.Category = CategoryExtension. TranslateFromEnglishToEnumEquivalents(new string[] { indentCategory }).FirstOrDefault(); } else { indentViewModel.Category = CategoryExtension. TranslateFromRussianToEnumEquivalents(new string[] { indentCategory }).FirstOrDefault(); } } indentViewModel.Price = priceOfIndent; indentViewModel.ImgSrc = imgSrc; indentViewModel.Customer = new CustomerDTO() { CustomerId = customerId }; IndentDTO indentDTO = _mapper.Map <IndentDTO>(indentViewModel); int? indentId; try { indentId = await _indentService.Create(indentDTO); } catch (ValidationException e) { TempData["ErrorMessage"] = e.Message; return(RedirectToAction("CreateIndent", "Customer")); } if (imgSrc != null) { imgSrc = imgSrc.Replace("indentId", indentId.ToString()); Request.Files[0].SaveAs(imgSrc); } return(RedirectToAction("GetCustomerIndents", "Customer")); }
private HelpModelForClientOpportunities SetClientOpportunities(IndentDTO indentDTO, Role?clientRole, int?clientId) { HelpModelForClientOpportunities clientPossibilities = new HelpModelForClientOpportunities(); switch (clientRole) { case Role.Customer: { if (clientId == indentDTO.Customer.CustomerId) { if (indentDTO.Executor == null) { clientPossibilities.customerIsAllowToSelectExecutor = true; } if (indentDTO.Executor != null && (indentDTO.Recall == null || indentDTO.Recall.CustomerMarkForExecutor == null)) { clientPossibilities.customerIsAllowToWriteRecall = true; } } return(clientPossibilities); } case Role.Executor: { if (indentDTO.Executor == null) { int executorId = clientId ?? default(int); ExecutorDTO clientExecutorDTO = _executorService.GetExecutorPropertiesForEdition(executorId); if (clientExecutorDTO.Categories.Count() > 0) { foreach (Category executorCategory in clientExecutorDTO.Categories) { if (executorCategory.Equals(indentDTO.CategoryId)) { clientPossibilities.executorIsAllowToSendResponce = true; foreach (var responce in indentDTO.Responces) { if (responce.Executor.ExecutorId == clientId) { clientPossibilities.executorIsAllowToSendResponce = false; } } } } } } if (indentDTO.Executor != null) { if (indentDTO.Executor.ExecutorId == clientId && (indentDTO.Recall == null || indentDTO.Recall.ExecutorMarkForCustomer == null)) { clientPossibilities.executorIsAllowToWriteRecall = true; } } return(clientPossibilities); } default: return(clientPossibilities); } }
///<summary> ///Returns view which contains indent model with: indent data, recalls, responces. ///Defines client opportunities to: write recall/responce, choose executor for indent. ///</summary> public ActionResult ShowIndent(int?id) { if (TempData["ErrorMessage"] != null) { ViewBag.ErrorMessage = TempData["ErrorMessage"]; } IndentDTO indentDTO = null; int indentId = id ?? default(int); string cacheKey = "show-indent-" + indentId.ToString(); indentDTO = HttpContext.Cache[cacheKey] as IndentDTO; if (indentDTO == null) { try { indentDTO = _indentService.Get(indentId); } catch (ValidationException e) { return(new HttpStatusCodeResult(404)); } HttpContext.Cache.Insert(cacheKey, indentDTO, null, DateTime.Now.AddSeconds(120), TimeSpan.Zero); } var claimIdentity = HttpContext.User.Identity as ClaimsIdentity; string role = ""; Role? clientRole = null; int? clientId = null; if (claimIdentity != null) { var roleClaim = claimIdentity.FindFirst(ClaimsIdentity.DefaultRoleClaimType); if (roleClaim != null) { role = roleClaim.Value.Trim(); clientRole = (Role)Enum.Parse(typeof(Role), role); } } var varClientId = Session["Id"]; if (varClientId != null) { clientId = Convert.ToInt32(varClientId); } HelpModelForClientOpportunities clientOpportunities = new HelpModelForClientOpportunities(); if (clientId != null && clientRole != null) { clientOpportunities = SetClientOpportunities(indentDTO, clientRole, clientId); } IndentViewModel indentViewModel = _mapper.Map <IndentViewModel>(indentDTO); IndentFullViewModel indentFullViewModel = new IndentFullViewModel() { indentViewModel = indentViewModel, clientOpportunities = clientOpportunities }; return(View(indentFullViewModel)); }
public async Task <ActionResult> SaveExecutorResponce(UserActivityViewModel activityModel, string indentPrice) { var clientId = Session["Id"]; if (clientId == null) { return(RedirectToAction("Registration", "Executor")); } int executorId = Convert.ToInt32(clientId); string executorName = Session["Name"].ToString(); double?priceOfIndent; Regex patternForPrice = new Regex(@"^[0-9]*\,?[0-9]+\s?$", RegexOptions.IgnoreCase); if (indentPrice == null) { priceOfIndent = null; } else if (patternForPrice.IsMatch(indentPrice.Trim())) { try { priceOfIndent = Convert.ToDouble(indentPrice.Trim()); } catch (Exception e) { TempData["ErrorMessage"] = "Были введены некорректные данные, попробуйте снова!"; return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); } } else { TempData["ErrorMessage"] = "Были введены некорректные данные, попробуйте снова!"; return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); } ResponceDTO responceDTO = new ResponceDTO() { Price = priceOfIndent, IndentId = activityModel.IndentId, Executor = new ExecutorDTO() { ExecutorId = executorId }, ResponceText = activityModel.Comment }; await _userActivityService.SaveResponce(responceDTO); string cacheKey = "show-indent-" + activityModel.IndentId.ToString(); IndentDTO cachedIndent = HttpContext.Cache[cacheKey] as IndentDTO; if (cachedIndent != null) { HttpContext.Cache.Remove(cacheKey); } NotificationDTO notificationDTO = GenerateNotification(activityModel, Role.Customer, "Responce"); notificationDTO.FromId = executorId; notificationDTO.FromName = executorName; await _userActivityService.SaveNotification(notificationDTO); return(RedirectToAction("ShowIndent", "Indent", new { id = activityModel.IndentId })); }