public async Task <ActionResult> Create(Warehouse warehouse) { var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); if (ModelState.IsValid) { db.Warehouses.Add(warehouse); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", warehouse.DepartmentId); ViewBag.DistrictId = new SelectList(CombosHelper.GetDistricts(), "DistrictId", "Name", warehouse.DistrictId); ViewBag.UserId = new SelectList(CombosHelper.GetUsers(user.CompanyId), "UserId", "UserName", warehouse.UserId); ViewBag.MainWarehouseId = new SelectList(db.MainWarehouses, "MainWarehouseId", "Name", warehouse.MainWarehouseId); return(View(warehouse)); }
// GET: Products/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Products products = db.Products.Find(id); if (products == null) { return(HttpNotFound()); } ViewBag.CategoryId = new SelectList(CombosHelper.GetCategories(products.CompanyId), "CategoryId", "Description", products.CategoryId); ViewBag.TaxId = new SelectList(CombosHelper.GetTaxes(products.CompanyId), "TaxId", "Description", products.TaxId); return(View(products)); }
public RegisterPageViewModel( INavigationService navigationService, IRegexHelper regexHelper, IApiService apiService, IFilesHelper filesHelper) : base(navigationService) { _navigationService = navigationService; _regexHelper = regexHelper; _apiService = apiService; _filesHelper = filesHelper; Title = Languages.Register; Image = App.Current.Resources["UrlNoImage"].ToString(); IsEnabled = true; User = new UserRequest(); Roles = new ObservableCollection <Role>(CombosHelper.GetRoles()); }
public ActionResult Create(Warehouse warehouse) { if (ModelState.IsValid) { db.Warehouses.Add(warehouse); var response = DBHelper.SaveChanges(db); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, response.Message); } ViewBag.CityId = new SelectList(CombosHelper.GetCities(warehouse.DepartmentId), "CityId", "Name", warehouse.CityId); //ViewBag.CompanyId = new SelectList(db.Companies, "CompanyId", "Name", warehouse.CompanyId); ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartment(), "DepartmentId", "Name", warehouse.DepartmentId); return(View(warehouse)); }
// GET: Cities/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } City city = db.Cities.Find(id); if (city == null) { return(HttpNotFound()); } ViewBag.ProvinceId = new SelectList( CombosHelper.GetProvinces(), "ProvinceId", "Name", city.ProvinceId); return(View(city)); }
public ActionResult Create([Bind(Include = "CityId,Nome,DepartamentsId")] City city) { if (ModelState.IsValid) { if (city.DepartamentsId is 0) { View(city); } ; db.Cities.Add(city); db.SaveChanges(); return(RedirectToAction("Index")); } //List<Departaments> list = CriarRegistroZero(db.Departaments.ToList()); ViewBag.DepartamentsId = new SelectList(CombosHelper.GetDepartaments(), "DepartamentsId", "Nome", city.DepartamentsId); return(View(city)); }
public ActionResult Create(NewOrderView view) { if (ModelState.IsValid) { var response = MovementsHelper.NewOrder(view, User.Identity.Name); if (response.Succedeed) { return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, response.Message); } var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); ViewBag.CustomerId = new SelectList(CombosHelper.GetCustomers(user.CompanyId), "CustomerId", "FullName"); view.Details = db.OrderDetailTmps.Where(odt => odt.UserName == User.Identity.Name).ToList(); return(View(view)); }
// GET: Zapaterias/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Zapateria zapateria = db.Zapaterias.Find(id); if (zapateria == null) { return(HttpNotFound()); } ViewBag.IdColony = new SelectList(CombosHelper.GetColonies(), "IdColony", "Description", zapateria.IdColony); ViewBag.IdMunicipality = new SelectList(CombosHelper.GetMunicipalities(), "IdMunicipality", "Description", zapateria.IdMunicipality); ViewBag.IdState = new SelectList(CombosHelper.GetStates(), "IdState", "Description", zapateria.IdState); return(View(zapateria)); }
public ActionResult AddOrEdit(int id = 0) { if (id == 0) { ViewBag.EquityFranquicia = new SelectList(CombosHelper.GetTipoCampañasAll(true), "Nombre", "Nombre"); ViewBag.TipoConfiguracion = new SelectList(CombosHelper.GetTipoConfiguracion(true), "Nombre", "Nombre"); return(PartialView(new TiendaConfiguracion())); } else { var tipo = db.TiendaConfiguracions.Where(x => x.TiendaConfiguracionId == id).FirstOrDefault().EquityFranquicia; var tipoC = db.TiendaConfiguracions.Where(x => x.TiendaConfiguracionId == id).FirstOrDefault().TipoConfiguracion; ViewBag.EquityFranquicia = new SelectList(CombosHelper.GetTipoCampañasAll(true), "Nombre", "Nombre", tipo); ViewBag.TipoConfiguracion = new SelectList(CombosHelper.GetTipoConfiguracion(true), "Nombre", "Nombre", tipoC); return(PartialView(db.TiendaConfiguracions.Where(x => x.TiendaConfiguracionId == id).FirstOrDefault())); } }
// GET: Products/Create public ActionResult Create() { var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); if (user == null) { return(RedirectToAction("Index", "Home")); } ViewBag.CategoryId = new SelectList(CombosHelper.GetCategories(user.CompanyId), "CategoryId", "Description"); ViewBag.TaxId = new SelectList(CombosHelper.GetTaxes(user.CompanyId), "TaxId", "Description"); var products = new Products { CompanyId = user.CompanyId }; return(View(products)); }
public ActionResult Create(Project project) { if (ModelState.IsValid) { db.Projects.Add(project); var response = DBHelper.SaveChanges(db); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, response.Message); } ViewBag.BankId = new SelectList(CombosHelper.GetBanks(), "BankId", "Name", project.BankId); ViewBag.CityId = new SelectList(CombosHelper.GetCities(project.DepartmentId), "CityId", "Name", project.CityId); ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", project.DepartmentId); return(View(project)); }
// GET: Customers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Customer customer = db.Customers.Find(id); if (customer == null) { return(HttpNotFound()); } ViewBag.CityId = new SelectList(CombosHelper.GetCities(), "CityId", "Name", customer.CityId); ViewBag.CountryId = new SelectList(CombosHelper.GetCountries(), "CountryId", "Name", customer.CountryId); return(View(customer)); }
// GET: Warehouses/Create public ActionResult Create() { var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); var warehouse = new Warehouse { CompanyId = user.CompanyId, }; //TODO still i don´t created the getmainwarehouses ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name"); ViewBag.DistrictId = new SelectList(CombosHelper.GetDistricts(), "DistrictId", "Name"); ViewBag.UserId = new SelectList(CombosHelper.GetUsers(user.CompanyId), "UserId", "UserName"); ViewBag.MainWarehouseId = new SelectList(db.MainWarehouses, "MainWarehouseId", "Name"); //var mainwarehouse = new MainWarehouse { MainWarehouseId = user.MainWarehouseId, }; return(View(warehouse)); }
// GET: Customers/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var customer = await db.Customers.FindAsync(id); if (customer == null) { return(HttpNotFound()); } ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", customer.DepartmentId); ViewBag.DistrictId = new SelectList(CombosHelper.GetDistricts(), "DistrictId", "Name", customer.DistrictId); return(View(customer)); }
public ActionResult Edit(Sale sale) { if (ModelState.IsValid) { db.Entry(sale).State = EntityState.Modified; var response = DBHelper.SaveChanges(db); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, response.Message); } var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); ViewBag.CustomerId = new SelectList(CombosHelper.GetCustomers(user.CompanyId), "CustomerId", "FullName", sale.CustomerId); ViewBag.WarehouseId = new SelectList(CombosHelper.GetWarehouses(user.CompanyId), "WarehouseId", "Name", sale.WarehouseId); return(View(sale)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RequestInstitute requestInstitute = db.RequestInstitutes.Find(id); if (requestInstitute == null) { return(HttpNotFound()); } ViewBag.CategoryId = new SelectList(CombosHelper.GetCategories(), "CategoryId", "Description", requestInstitute.CategoryId); ViewBag.ColonyId = new SelectList(CombosHelper.GetColonies(0), "ColonyId", "Description", requestInstitute.ColonyId); ViewBag.MunicipalityId = new SelectList(CombosHelper.GetMunicipalities(0), "MunicipalityId", "Description", requestInstitute.MunicipalityId); ViewBag.StateId = new SelectList(CombosHelper.GetStates(), "StateId", "Description", requestInstitute.StateId); return(View(requestInstitute)); }
// GET: Sales/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Sale sale = db.Sales.Find(id); if (sale == null) { return(HttpNotFound()); } var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); ViewBag.CustomerId = new SelectList(CombosHelper.GetCustomers(user.CompanyId), "CustomerId", "FullName", sale.CustomerId); ViewBag.WarehouseId = new SelectList(CombosHelper.GetWarehouses(user.CompanyId), "WarehouseId", "Name", sale.WarehouseId); return(View(sale)); }
// GET: VotingPlaces/Create public ActionResult Create() { ViewBag.CountryId = new SelectList( CombosHelper.GetCountries(), "CountryId", "Name"); ViewBag.DepartmentId = new SelectList( CombosHelper.GetDepartments(), "DepartmentId", "Name"); ViewBag.CityId = new SelectList( CombosHelper.GetCities(), "CityId", "Name"); return(View()); }
public ActionResult Create(User user) { if (ModelState.IsValid) { db.Users.Add(user); var responsse = DBHelper.SaveChanges(db); if (responsse.Succeded) { UsersHelper.CreateUserASP(user.UserName, "User"); } else { ModelState.AddModelError(string.Empty, responsse.Message); return(View(user)); } if (user.PhotoFile != null) { var pic = string.Empty; var folder = "~/Content/Users"; pic = FilesHelper.GetNamePhoto(user.UserId); if (pic != null) { var response = FilesHelper.UploadPhoto(user.PhotoFile, pic, folder); user.Photo = string.Format("{0}/{1}", folder, pic); db.Entry(user).State = EntityState.Modified; var respons = DBHelper.SaveChanges(db); if (!respons.Succeded) { ModelState.AddModelError(string.Empty, respons.Message); return(View(user)); } } } return(RedirectToAction("Index")); } ViewBag.CityId = new SelectList(CombosHelper.GetCities(user.DepartmentId), "CityId", "Name", user.CityId); ViewBag.CompanyId = new SelectList(CombosHelper.GetCompanies(), "CompanyId", "Name", user.CompanyId); ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", user.DepartmentId); return(View(user)); }
public ActionResult Create(Product product) { var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); if (ModelState.IsValid) { db.Products.Add(product); try { db.SaveChanges(); if (product.ImageFile != null) { var folder = "~/Content/Products"; var file = string.Format("{0}.jpg", product.ProductId); var response = FilesHelper.UploadPhoto(product.ImageFile, folder, file); if (response) { var pic = string.Format("{0}/{1}", folder, file); product.Image = pic; db.Entry(product).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, "Ya existe un registro con el mismo valor."); } else { ModelState.AddModelError(string.Empty, ex.Message); } } } ViewBag.CategoryId = new SelectList(CombosHelper.GetCategories(user.CompanyId), "CategoryId", "Description", product.CategoryId); ViewBag.TaxId = new SelectList(CombosHelper.GetTaxes(user.CompanyId), "TaxId", "Description", product.TaxId); return(View(product)); }
public ActionResult AddProduct(AddproductView view) { if (ModelState.IsValid) { var orderDetailTmpConsulta = db.OrderDetailTmp.Where(o => o.UserId == 1 && o.PartId == view.PartId).FirstOrDefault(); if (orderDetailTmpConsulta == null) { var priceListParts = db.PriceListParts.Where(p => p.PriceListId == view.PriceListId && p.PartId == view.PartId).FirstOrDefault(); var part = db.Parts.Find(view.PartId); var orderDetailTmp = new OrderDetailTmp { OrderQty = view.OrderQty, PartId = view.PartId, PartNum = part.PartNum, PartDescription = part.PartDescription, PriceListPartId = priceListParts.PriceListPartId, Reference = view.Reference, TaxAmt = 0, Total = view.OrderQty * view.UnitPrice, UnitPrice = view.UnitPrice, UserId = 1 }; db.OrderDetailTmp.Add(orderDetailTmp); } else { orderDetailTmpConsulta.OrderQty += view.OrderQty; db.Entry(orderDetailTmpConsulta).State = EntityState.Modified; } db.SaveChanges(); //view.OrderQty = 0; //view.UnitPrice = 0; //view.Reference = 0; // return View(view); return(RedirectToAction("Create")); } ViewBag.PriceListId = new SelectList(db.PriceLists.Where(p => p.PriceListId == view.PriceListId), "PriceListId", "ListDescription"); ViewBag.PartId = new SelectList(CombosHelper.GetPriceListPart(view.PriceListId), "PartId", "PartDescription"); return(View(view)); }
public ActionResult Create(VotingPlace votingPlace) { if (ModelState.IsValid) { db.VotingPlaces.Add(votingPlace); 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, "Ya existe un Registro con esa descripción"); } else { ModelState.AddModelError(string.Empty, ex.ToString()); } } } ViewBag.CountryId = new SelectList( CombosHelper.GetCountries(), "CountryId", "Name", votingPlace.CountryId); ViewBag.DepartmentId = new SelectList( CombosHelper.GetDepartments(), "DepartmentId", "Name", votingPlace.DepartmentId); ViewBag.CityId = new SelectList( CombosHelper.GetCities(), "CityId", "Name", votingPlace.CityId); return(View(votingPlace)); }
public ActionResult DeleteConfirmed(int id) { var votingPlace = db.VotingPlaces.Find(id); db.VotingPlaces.Remove(votingPlace); try { db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message.Contains("REFERENCE")) { ModelState.AddModelError(string.Empty, "El registro no se puede borrar porque tiene registros relacionados"); } else { ModelState.AddModelError(string.Empty, ex.ToString()); } } ViewBag.CountryId = new SelectList( CombosHelper.GetCountries(), "CountryId", "Name", votingPlace.CountryId); ViewBag.DepartmentId = new SelectList( CombosHelper.GetDepartments(), "DepartmentId", "Name", votingPlace.DepartmentId); ViewBag.CityId = new SelectList( CombosHelper.GetCities(), "CityId", "Name", votingPlace.CityId); return(View(votingPlace)); }
public ActionResult Create(Company company) { if (ModelState.IsValid) { try { db.Companies.Add(company); db.SaveChanges(); if (company.LogoFile != null) { var folder = "~/Content/Logos"; var file = string.Format("{0}.jpg", company.CompanyId); var response = FilesHelper.UploadPhoto(company.LogoFile, folder, file); if (response) { var pic = string.Format("{0}/{1}", folder, file); company.Logo = pic; db.Entry(company).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, "Ya existe un registro con el mismo valor."); } else { ModelState.AddModelError(string.Empty, ex.Message); } } } ViewBag.CityId = new SelectList(CombosHelper.GetCities(), "CityId", "Nombre", company.CityId); ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Nombre", company.DepartmentId); return(View(company)); }
public ActionResult Create(User user) { try { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); UsersHelper.CreateUserASP(user.UserName, "User"); if (user.PhotoFile != null) { var folder = "~/Content/FotoPersonal"; var name = string.Format("{0}.jpg", user.UserId); var response = FilesHelper.UploadPhoto(user.PhotoFile, folder, name); if (response) { var pic = string.Format("{0}/{1}", folder, name); user.Photo = pic; db.Entry(user).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, "Duplicate records not allowed"); } else { ModelState.AddModelError(String.Empty, ex.Message); } } ViewBag.CityId = new SelectList(CombosHelper.GetCities(), "CityId", "Name", user.CityId); ViewBag.CompanyId = new SelectList(CombosHelper.GetCompanies(), "CompanyId", "Name", user.CompanyId); ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", user.DepartmentId); return(View(user)); }
public ActionResult Create(Customer customer) { if (ModelState.IsValid) { using (var transaction = db.Database.BeginTransaction()) { try { db.Customers.Add(customer); var response = DBHelper.SaveChanges(db); if (!response.Succedeed) { ModelState.AddModelError(string.Empty, response.Message); transaction.Rollback(); ViewBag.CityId = new SelectList(CombosHelper.GetCities(), "CityId", "Name", customer.CityId); ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", customer.DepartmentId); } UserHelper.CreateUserASP(customer.UserName, "Customer"); var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); var companyCustomer = new CompanyCustomer { CompanyId = user.CompanyId, CustomerId = customer.CustomerId, }; db.CompanyCustomers.Add(companyCustomer); db.SaveChanges(); transaction.Commit(); return(RedirectToAction("Index")); } catch (Exception ex) { transaction.Rollback(); ModelState.AddModelError(string.Empty, ex.Message); } } } ViewBag.CityId = new SelectList(CombosHelper.GetCities(), "CityId", "Name", customer.CityId); ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", customer.DepartmentId); return(View(customer)); }
// GET: Orders/Create public ActionResult Create() { var user = db.Users.Where(c => c.UserName == User.Identity.Name).FirstOrDefault(); if (user == null) { return(RedirectToAction("Index", "Home")); } ViewBag.CustomerId = new SelectList(CombosHelper.GetCustomers(user.CompanyId), "CustomerId", "FullName"); //ViewBag.StateId = new SelectList(db.States, "StateId", "Description"); var view = new NewOrderView { Date = DateTime.Now, Details = db.OrderDetailTmps.Where(odt => odt.UserName == User.Identity.Name).ToList(), }; view.Details = db.OrderDetailTmps.Where(odt => odt.UserName == User.Identity.Name).ToList(); return(View(view)); }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var product = await db.Products.FindAsync(id); if (product == null) { return(HttpNotFound()); } ViewBag.CategoryId = new SelectList(CombosHelper.GetCategories(), "CategoryId", "Description", product.CategoryId); var view = ToView(product); return(View(view)); }
public ActionResult Create([Bind(Include = "CityId,Name,DepartmentId")] City city) { if (ModelState.IsValid) { db.Cities.Add(city); var response = DBHelper.SaveChanges(db); if (response.Succeeded) { return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, response.Message); } } ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name"); return(View(city)); }
// GET: WareHouses/Create public ActionResult Create() { var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); if (user == null) { return(RedirectToAction("Index", "Home")); } var ware = new WareHouse { CompanyId = user.CompanyId }; ViewBag.CityId = new SelectList(CombosHelper.GetCities(0), "CityId", "Name"); ViewBag.DepartamentsId = new SelectList(CombosHelper.GetDepartments(), "DepartamentsId", "Name"); return(View(ware)); }