//// GET: Provider/Details/5 //public ActionResult Details(int? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // ProviderViewModel providerViewModel = db.ProviderViewModels.Find(id); // if (providerViewModel == null) // { // return HttpNotFound(); // } // return View(providerViewModel); //} // GET: Provider/Create public ActionResult Create() { var model = TempData["NewProvider"]; var modelBL = _mapper.Map <ProviderBL>(model); _service.Create(modelBL); return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> Create(Provider provider) { if (provider == null) { return(RedirectToAction(nameof(Error))); } await _providerService.Create(provider); return(RedirectToAction(nameof(Index))); }
public IActionResult Incluir(Data.Models.Provider categoria) { if (!ModelState.IsValid) { return(View(categoria)); } var result = _providerService.Create(categoria); TempData.Put("Notification", result); return(RedirectToAction("Principal")); }
public ActionResult Create(ProviderForm providerForm) { if (!ModelState.IsValid) { return(View(providerForm)); } var provider = providerForm.ToProvider(); _providerService.Create(provider); return(RedirectToAction("Index", new ProviderListFiltersModel().GetRouteValues()).WithSuccess("Camion Creado")); }
public async void Execute(object parameter) { try { await _providerDataService.Create(new Provider() { Name = _addProvideriewModel.Name }); } catch (Exception e) { MessageBox.Show(e.Message); } }
public ActionResult Create(CreateProviderViewModel model) { if (!ModelState.IsValid) { model.Categories = _providerMapper.GetCreateProviderViewModel().Categories; return(View(model)); } var creator = _userService.FindByUserName(User.Identity.GetUserName()); var provider = _providerMapper.MapToProviderModel(model, creator); _providerService.Create(provider); return(RedirectToAction("Show", new { id = _providerService.GetAll().Last().Id })); }
public ActionResult Create(SearchProvider model) { if (!ModelState.IsValid) { return(View(model)); } try { _service.Create(model); return(RedirectToAction("Index")); } catch { return(View()); } }
public void Can_Add_Provider() { //Arrange var Id = 1; var emp = new SearchProvider { Name = "Google" }; _mockRepository.Setup(m => m.Add(emp)).Returns((SearchProvider e) => { e.Id = Id; return(e); }); //Act _service.Create(emp); //Assert Assert.AreEqual(Id, emp.Id); _mockUnitWork.Verify(m => m.Commit(), Times.Once); }
public ActionResult Registration(RegistrationModel model) { var statusRegistration = false; var messageRegistration = string.Empty; ViewBag.Administrations = _administrationService.GetAllAdministrationsKeyValuePairs(); ViewBag.Vendors = _vendorService.GetAllVendorsKeyValuePairs(); switch (model.RoleId) { case default(int): ModelState.AddModelError("RoleId", "Оберіть роль"); break; case (int)AreaTypes.Customer: { if (model.AdministrationId == null || model.AdministrationId.Value == default(int)) { ModelState.AddModelError("AdministrationId", "Оберіть адміністрацію"); } break; } } if (ModelState.IsValid) { // Email Verification var userName = _userService.GetUserByEmail(model.Email); if (userName != null) { ModelState.AddModelError("Warning Email", "Ця електронна адреса уже зареєстрована"); return(View(model)); } var user = _peopleFactory.PrepareUser(model); var address = _addressModelFactory.PrepareAddressFromRegistrationModel(model); if (model.RoleId == (int)AreaTypes.Customer) { var customer = _peopleFactory.PrepareCustomer(model, user, address); _customerService.Create(customer); } if (model.RoleId == (int)AreaTypes.Vendor) { var provider = _peopleFactory.PrepareProvider(model, user, address); _providerService.Create(provider); } //Verification Email //VerificationEmail(registrationView.Email, registrationView.ActivationCode.ToString()); messageRegistration = "Ви були успішно зареєстровані"; statusRegistration = true; } else { var errors = ModelState.Values.SelectMany(v => v.Errors).ToList(); messageRegistration = "Перевірте свої дані!"; } ViewBag.Message = messageRegistration; ViewBag.Status = statusRegistration; return(View(model)); }