public ActionResult SendRequestForScrapping(SendRequestForScrappingViewModel model) { var asset = this.assetService.GetById(model.InventoryNumber); //Verify if asset is from user organisation if (!this.IsMegaAdmin()) { if (asset.Site.OrganisationId != this.userService.GetUserOrganisationId(this.User.Identity.GetUserId())) { return(Redirect("/Home/NotAuthorized")); } } //Check is there a request for this asset if (this.requestForScrappingService.Exist(model.InventoryNumber)) { return(Redirect("/AssetsActions/ScrappingAsset/ThereIsRequest")); } var request = new RequestForScrapping { AssetId = model.InventoryNumber, IsApproved = false, FromId = model.FromId, DateOfSend = DateTime.Now }; this.requestForScrappingService.Add(request); //Add event that there is a new request this.eventService.AddForUserGroup(new Event { Content = "There is a new sccraping request for approving !", Date = DateTime.Now, EventRelocationUrl = "/AssetsActions/ScrappingAsset/RequestsForApproving" }, "Approve request for scrapping", this.userService.GetUserOrganisationId(this.User.Identity.GetUserId())); return(Redirect("/AssetsActions/ScrappingAsset/SuccessSend")); }
public ActionResult SendRequestForScrapping(string id) { var asset = this.assetService.GetById(id); //Verify if asset is from user organisation if (!this.IsMegaAdmin()) { if (asset.Site.OrganisationId != this.userService.GetUserOrganisationId(this.User.Identity.GetUserId())) { return(Redirect("/Home/NotAuthorized")); } } //Check status of asset if (asset.Status != "Active" && asset.Status != "Broken") { return(Redirect("/AssetsActions/Asset/AssetIsNotActive")); } var user = this.userService.GetById(this.User.Identity.GetUserId()); var viewModel = new SendRequestForScrappingViewModel { Brand = asset.Brand, Producer = asset.Producer, InventoryNumber = asset.InventoryNumber, ItemModel = asset.Model, Guarantee = asset.Guarantee, Price = asset.Price.Value, Type = asset.Type.ToString(), SiteName = asset.Site.Name, FromId = user.Id, FromName = (user.FirstName != null && user.SecondName != null && user.LastName != null) ? user.FirstName + " " + user.SecondName + " " + user.LastName : user.Email, Currency = asset.Price.Currency.Code }; return(View(viewModel)); }
public ActionResult ViewRequestForApproving(int id) { var request = this.requestForScrappingService.GetById(id); //Verify if request is from user organisation if (!this.IsMegaAdmin()) { if (request.From.Site.OrganisationId != this.userService.GetUserOrganisationId(this.User.Identity.GetUserId())) { return(Redirect("/Home/NotAuthorized")); } } var asset = request.Asset; var user = request.From; var viewModel = new SendRequestForScrappingViewModel { Brand = asset.Brand, Producer = asset.Producer, InventoryNumber = asset.InventoryNumber, ItemModel = asset.Model, Guarantee = asset.Guarantee, Price = asset.Price.Value, Type = asset.Type.ToString(), SiteName = asset.Site.Name, FromId = user.Id, FromName = (user.FirstName != null && user.SecondName != null && user.LastName != null) ? user.FirstName + " " + user.SecondName + " " + user.LastName : user.Email, Id = id, Currency = asset.Price.Currency.Code }; return(View(viewModel)); }