// GET: Products/Create public ActionResult Create() { var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); ViewBag.CategoryId = new SelectList( ComboBoxHelpers. GetCategories( user.CompanyId), "CategoryId", "Description"); ViewBag.TaxId = new SelectList( ComboBoxHelpers. GetTaxes( user.CompanyId), "TaxId", "Description"); var product = new Product { CompanyId = user.CompanyId, }; return(View(product)); }
// GET: WareHouses/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult( HttpStatusCode.BadRequest)); } var wareHouse = db.WareHouses.Find(id); if (wareHouse == null) { return(HttpNotFound()); } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(), "CityId", "NameCity", wareHouse.CityId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", wareHouse.StateId); return(View(wareHouse)); }
public async Task <IActionResult> ApiResource(ApiResourceDto apiResource) { if (!ModelState.IsValid) { return(View(apiResource)); } ComboBoxHelpers.PopulateValuesToList(apiResource.UserClaimsItems, apiResource.UserClaims); int apiResourceId; if (apiResource.Id == 0) { apiResourceId = await _apiResourceService.AddApiResourceAsync(apiResource); } else { apiResourceId = apiResource.Id; await _apiResourceService.UpdateApiResourceAsync(apiResource); } SuccessNotification(string.Format(_localizer["SuccessAddApiResource"], apiResource.Name), _localizer["SuccessTitle"]); return(RedirectToAction(nameof(ApiResource), new { Id = apiResourceId })); }
public async Task <IActionResult> ApiResource(ApiResourceDto apiResource) { if (!ModelState.IsValid) { return(Success(apiResource)); } ComboBoxHelpers.PopulateValuesToList(apiResource.UserClaimsItems, apiResource.UserClaims); int apiResourceId; if (apiResource.Id == 0) { apiResourceId = await _apiResourceService.AddApiResourceAsync(apiResource); } else { apiResourceId = apiResource.Id; await _apiResourceService.UpdateApiResourceAsync(apiResource); } return(Success(new { Id = apiResourceId })); }
public ActionResult Create(Tax tax) { if (ModelState.IsValid) { db.Taxes.Add(tax); var response = DBHelpers.SaveChanges(db); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); } ViewBag.CompanyId = new SelectList( ComboBoxHelpers. GetCompanies(), "CompanyId", "NameCompany", tax.CompanyId); return(View(tax)); }
// GET: Orders/Create public ActionResult Create() { var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); ViewBag.CustomerId = new SelectList( ComboBoxHelpers. GetCustomers( user.CompanyId), "CustomerID", "FullName"); var newView = new NewOrderView { DateOrder = DateTime.Now, Details = db.OrderDetailTmps. Where(odt => odt.UserName == User.Identity.Name). ToList(), }; return(View(newView)); }
// GET: WareHouses/Create public ActionResult Create() { var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(), "CityId", "NameCity"); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState"); var warehouse = new WareHouse { CompanyId = user.CompanyId, }; return(View(warehouse)); }
// GET: Cities/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult( HttpStatusCode.BadRequest)); } var city = db.Cities.Find(id); if (city == null) { return(HttpNotFound()); } ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", city.StateId); return(View(city)); }
// GET: Users/Create public ActionResult Create() { ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(0), "CityId", "NameCity"); ViewBag.CompanyId = new SelectList( ComboBoxHelpers. GetCompanies(), "CompanyId", "NameCompany"); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState"); return(View()); }
public async virtual Task <ApiScopesDto> BuildApiScopeViewModelAsync(ApiScopesDto apiScope) { ComboBoxHelpers.PopulateValuesToList(apiScope.UserClaimsItems, apiScope.UserClaims); apiScope.ResourceName = await GetApiResourceNameAsync(apiScope.ApiResourceId); return(apiScope); }
public ActionResult AddProduct(AddProductView view) { var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); if (ModelState.IsValid) { var orderDetailTmp = db.OrderDetailTmps. Where(odt => odt.UserName == User.Identity.Name && odt.ProductID == view.ProductId). FirstOrDefault(); if (orderDetailTmp == null) { var product = db.Products.Find(view.ProductId); orderDetailTmp = new OrderDetailTmp { Description = product.Description, Price = product.Price, ProductID = product.ProductID, Quantity = view.Quantity, TaxRate = product.Tax.Rate, UserName = User.Identity.Name, }; db.OrderDetailTmps. Add(orderDetailTmp); } else { orderDetailTmp.Quantity += view.Quantity; db.Entry(orderDetailTmp).State = EntityState.Modified; } db.SaveChanges(); return(RedirectToAction("Create")); } ViewBag.ProductId = new SelectList( ComboBoxHelpers. GetProducts( user.CompanyId), "ProductID", "Description"); return(PartialView(view)); }
private void PopulateClientRelations(ClientDto client) { ComboBoxHelpers.PopulateValuesToList(client.AllowedScopesItems, client.AllowedScopes); ComboBoxHelpers.PopulateValuesToList(client.PostLogoutRedirectUrisItems, client.PostLogoutRedirectUris); ComboBoxHelpers.PopulateValuesToList(client.IdentityProviderRestrictionsItems, client.IdentityProviderRestrictions); ComboBoxHelpers.PopulateValuesToList(client.RedirectUrisItems, client.RedirectUris); ComboBoxHelpers.PopulateValuesToList(client.AllowedCorsOriginsItems, client.AllowedCorsOrigins); ComboBoxHelpers.PopulateValuesToList(client.AllowedGrantTypesItems, client.AllowedGrantTypes); }
// GET: Cities/Create public ActionResult Create() { ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState"); return(View()); }
public ActionResult Edit(WareHouse wareHouse) { if (ModelState.IsValid) { db.Entry(wareHouse).State = EntityState.Modified; try { db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException. InnerException != null && ex.InnerException. InnerException.Message. Contains("_Index")) { ModelState. AddModelError( string.Empty, "You Can't Add a New Record, Because There is Already One"); } else { ModelState. AddModelError( string.Empty, ex.Message); } } } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(), "CityId", "NameCity", wareHouse.CityId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", wareHouse.StateId); return(View(wareHouse)); }
// GET: AddProducts/Create public ActionResult AddProduct() { var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); ViewBag.ProductId = new SelectList( ComboBoxHelpers. GetProducts( user.CompanyId), "ProductID", "Description"); return(PartialView()); }
public ActionResult Create(Category category) { if (ModelState.IsValid) { db.Categories.Add(category); try { db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException. InnerException != null && ex.InnerException. InnerException.Message. Contains("_Index")) { ModelState. AddModelError( string.Empty, "You Can't Add a New Record, Because There is Already One"); } else { ModelState. AddModelError( string.Empty, ex.Message); } } } ViewBag.CompanyId = new SelectList( ComboBoxHelpers. GetCompanies(), "CompanyId", "NameCompany", category.CompanyId); return(View(category)); }
// GET: Users/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult( HttpStatusCode.BadRequest)); } var user = db.Users.Find(id); if (user == null) { return(HttpNotFound()); } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(user.StateId), "CityId", "NameCity", user.CityId); ViewBag.CompanyId = new SelectList( ComboBoxHelpers. GetCompanies(), "CompanyId", "NameCompany", user.CompanyId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", user.StateId); return(View(user)); }
// GET: Products/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult( HttpStatusCode.BadRequest)); } var product = db.Products.Find(id); if (product == null) { return(HttpNotFound()); } var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); ViewBag.CategoryId = new SelectList( ComboBoxHelpers. GetCategories( user.CompanyId), "CategoryId", "Description", product.CategoryId); ViewBag.TaxId = new SelectList( ComboBoxHelpers. GetTaxes( user.CompanyId), "TaxId", "Description", product.TaxId); return(View(product)); }
public ActionResult Create(NewOrderView view) { if (ModelState.IsValid) { var response = MovementHelpers. NewOrder( view, User.Identity.Name); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); } var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); ViewBag.CustomerId = new SelectList( ComboBoxHelpers. GetCustomers( user.CompanyId), "CustomerID", "FullName", view.CustomerId); view.Details = db.OrderDetailTmps. Where(odt => odt.UserName == User.Identity.Name). ToList(); return(View(view)); }
// GET: Customers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult( HttpStatusCode.BadRequest)); } var customer = db.Customers.Find(id); if (customer == null) { return(HttpNotFound()); } var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(customer.StateId), "CityId", "NameCity", customer.CityId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", customer.StateId); return(View(customer)); }
public ActionResult Create(City city) { if (ModelState.IsValid) { db.Cities.Add(city); try { db.SaveChanges(); if (city.FlagFile != null) { var folder = "~/Content/Cities/FlagsCities"; var file = string.Format("{0}.jpg", city.CityId); var response = FilesHelpers. UploadPhoto( city.FlagFile, folder, file); if (response) { var pic = string.Format("{0}/{1}", folder, file); city.Flag = pic; db.Entry(city).State = EntityState.Modified; db.SaveChanges(); } } if (city.ShieldFile != null) { var folder1 = "~/Content/Cities/ShieldsCities"; var file1 = string.Format("{0}.jpg", city.CityId); var response1 = FilesHelpers. UploadPhoto( city.ShieldFile, folder1, file1); if (response1) { var pic = string.Format("{0}/{1}", folder1, file1); city.Shield = pic; db.Entry(city).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("Index")); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException. InnerException != null && ex.InnerException. InnerException.Message. Contains("_Index")) { ModelState. AddModelError( string.Empty, "You Can't Add a New Record, Because There is Already One"); } else { ModelState. AddModelError( string.Empty, ex.Message); } } } ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", city.StateId); return(View(city)); }
public ApiScopesDto BuildApiScopeViewModel(ApiScopesDto apiScope) { ComboBoxHelpers.PopulateValuesToList(apiScope.UserClaimsItems, apiScope.UserClaims); return(apiScope); }
public IdentityResourceDto BuildIdentityResourceViewModel(IdentityResourceDto identityResource) { ComboBoxHelpers.PopulateValuesToList(identityResource.UserClaimsItems, identityResource.UserClaims); return(identityResource); }
public ActionResult Create(Customer customer) { var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); if (ModelState.IsValid) { db.Customers.Add(customer); var response = DBHelpers.SaveChanges(db); if (response.Succeeded) { if (customer.LogoCFile != null) { var folder = "~/Content/Customers"; var file = string.Format("{0}.jpg", customer.CustomerID); var response0 = FilesHelpers. UploadPhoto( customer.LogoCFile, folder, file); if (response0) { var pic = string.Format("{0}/{1}", folder, file); customer.LogoC = pic; db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(customer.StateId), "CityId", "NameCity", customer.CityId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", customer.StateId); return(View(customer)); }
public ActionResult Create(User user) { if (ModelState.IsValid) { db.Users.Add(user); var response = DBHelpers.SaveChanges(db); if (response.Succeeded) { UsersHelpers. CreateUserASP(user.UserName, "User"); if (user.PhotoFile != null) { var folder = "~/Content/Photos"; var file = string.Format("{0}.jpg", user.UserID); var response0 = FilesHelpers. UploadPhoto( user.PhotoFile, folder, file); if (response0) { var pic = string.Format("{0}/{1}", folder, file); user.Photo = pic; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(user.StateId), "CityId", "NameCity", user.CityId); ViewBag.CompanyId = new SelectList( ComboBoxHelpers. GetCompanies(), "CompanyId", "NameCompany", user.CompanyId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", user.StateId); return(View(user)); }
public ActionResult Create(Company company) { if (ModelState.IsValid) { db.Companies.Add(company); var response = DBHelpers.SaveChanges(db); if (response.Succeeded) { if (company.LogoFile != null) { var folder = "~/Content/Logos"; var file = string.Format("{0}.jpg", company.CompanyId); var response0 = FilesHelpers. UploadPhoto( company.LogoFile, folder, file); if (response0) { var pic = string.Format("{0}/{1}", folder, file); company.Logo = pic; db.Entry(company).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); } ViewBag.CityId = new SelectList( ComboBoxHelpers. GetCities(company.StateId), "CityId", "NameCity", company.CityId); ViewBag.StateId = new SelectList( ComboBoxHelpers. GetStates(), "StateId", "NameState", company.StateId); return(View(company)); }
public ActionResult Edit(Product product) { var user = db.Users. Where(us => us.UserName == User.Identity.Name). FirstOrDefault(); if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; if (product.ImageFile != null) { var folder = "~/Content/Products"; var pic = string.Empty; var file = string.Format("{0}.jpg", product.ProductID); var response0 = FilesHelpers. UploadPhoto( product.ImageFile, folder, file); if (response0) { pic = string.Format("{0}/{1}", folder, product.ProductID); product.Image = pic; } } var response = DBHelpers.SaveChanges(db); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError( string.Empty, response.Message); } ViewBag.CategoryId = new SelectList( ComboBoxHelpers. GetCategories( user.CompanyId), "CategoryId", "Description", product.CategoryId); ViewBag.TaxId = new SelectList( ComboBoxHelpers. GetTaxes( user.CompanyId), "TaxId", "Description", product.TaxId); return(View(product)); }