public ActionResult EditPage(int id) { PageVM model; using (StoreDb storeDb = new StoreDb()) { PagesDTO pagesDTO = storeDb.Pages.Find(id); if (pagesDTO == null) { return(Content("This page does not exist!!!")); } model = new PageVM(pagesDTO); return(View(model)); } }
public ActionResult AddPage(PageVM model) { if (!ModelState.IsValid) { return(View(model)); } using (StoreDb storeDb = new StoreDb()) { string charac; //характеристика або опис (атрибут бд) PagesDTO pagesDTO = new PagesDTO(); pagesDTO.Name = model.Name.ToUpper(); if (string.IsNullOrWhiteSpace(model.Small_Characteristic)) { charac = model.Name.Replace(" ", "-").ToLower(); } else { charac = model.Small_Characteristic.Replace(" ", "-").ToLower(); } if (storeDb.Pages.Any(x => x.Name == model.Name)) { ModelState.AddModelError("", "This name already exist!!!"); return(View(model)); } else if (storeDb.Pages.Any(x => x.Small_Characteristic == model.Small_Characteristic)) { ModelState.AddModelError("", "This small characteristic already exist!!!"); return(View(model)); } pagesDTO.Small_Characteristic = charac; pagesDTO.Characteristic = model.Characteristic; pagesDTO.Name = model.Name; pagesDTO.Sorting = 100; storeDb.Pages.Add(pagesDTO); storeDb.SaveChanges(); } TempData["SM"] = "You have added a new page"; return(RedirectToAction("Index")); }
public StoreController(StoreDb context, IConfiguration configuration, ICategoryUndercutters _undercuttersCategoryGetter, IBrandUndercutters _undercuttersBrandGetter, IProductUndercutters _undercuttersProductGetter, IProductRepository productRepository, IBrandRepository brandRepository, ICategoryRepository categoryRepository, IMapper mapper) { _configuration = configuration; undercuttersCategoryGetter = _undercuttersCategoryGetter; undercuttersBrandGetter = _undercuttersBrandGetter; undercuttersProductGetter = _undercuttersProductGetter; _productRepository = productRepository; _brandRepository = brandRepository; _categoryRepository = categoryRepository; _mapper = mapper; setupUndercutersClient(); }
public ActionResult EditPage(PageVM model) { if (!ModelState.IsValid) { return(View(model)); } using (StoreDb storeDb = new StoreDb()) { int id = model.Id; string charac; PagesDTO pagesDTO = storeDb.Pages.Find(id); pagesDTO.Name = model.Name; pagesDTO.Characteristic = model.Characteristic; if (string.IsNullOrWhiteSpace(model.Small_Characteristic)) { charac = model.Name.Replace(" ", "-").ToLower(); } else { charac = model.Small_Characteristic.Replace(" ", "-").ToLower(); } if (storeDb.Pages.Where(x => x.Id != id).Any(x => x.Name == model.Name)) { ModelState.AddModelError("", "That Name already exist."); return(View(model)); } else if (storeDb.Pages.Where(x => x.Id != id).Any(x => x.Small_Characteristic == charac)) { ModelState.AddModelError("", "That Small Characreristic already exist."); return(View(model)); } pagesDTO.Small_Characteristic = charac; pagesDTO.Name = model.Name; pagesDTO.Characteristic = model.Characteristic; storeDb.SaveChanges(); } TempData["SM"] = "You have edited the page."; return(RedirectToAction("EditPage")); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { UserDTO user = null; using (StoreDb db = new StoreDb()) { user = db.User.FirstOrDefault(u => u.Login == model.Name); } if (user == null) { // создаем нового пользователя using (StoreDb db = new StoreDb()) { db.User.Add(new UserDTO { Login = model.Name, Password = model.Password }); db.SaveChanges(); user = db.User.Where(u => u.Login == model.Name && u.Password == model.Password).FirstOrDefault(); } // если пользователь удачно добавлен в бд if (user != null) { FormsAuthentication.SetAuthCookie(model.Name, true); return(RedirectToAction("Index", "Home")); } } else { ModelState.AddModelError("", "Пользователь с таким логином уже существует"); } } return(View(model)); }
public void Setup() { _storeDb = null; }
public CategoriesController(StoreDb context, ICategoryRepository categoryRepository, IMapper mapper) { _context = context; _categoryRepository = categoryRepository; _mapper = mapper; }
public ItemsRepository(StoreDb db) { this.db = db; }
public BrandRepository(StoreDb context, IMapper mapper) { _context = context; _mapper = mapper; }
private static void NewMethod(StoreDb ctx) { ctx.Courses.Add(new Domin.Course { Name = "Asp .Net Mvc" }); }
public ProductRepository(StoreDb context, IMapper mapper) { _context = context; _mapper = mapper; }
public StoreController(StoreDb context) { _context = context; }
public CategoriesController(StoreDb context) { _context = context; }
public AccTransfersService(StoreDb context) { _StoreDb = context; }
public GroupsRepository(StoreDb db) { this.db = db; }
public AccountsService(StoreDb context) { _StoreDb = context; }
public CategoryRepository(StoreDb context, IMapper mapper) { _context = context; _mapper = mapper; }
public BasketController() { _storeContext = new StoreDb(); }
public ProductsController(StoreDb context) { _context = context; }
public void Import(string catalogAsJson) { this.StoreDb = JsonConvert.DeserializeObject <StoreDb>(catalogAsJson); }
public ItemController() { _storeContext = new StoreDb(); _itemListModelFactory = new ItemListModelFactory(); }
public ExportsController(StoreDb context) { _context = context; }
public BrandsController(StoreDb context) { _context = context; }