public ActionResult NewPharmacy() { var viewModel = new PharmacyViewModel { }; return(View("PharmacyForm", viewModel)); }
public ActionResult Create(PharmacyViewModel pharmacyViewModel) { if (!ModelState.IsValid) { return(View()); } var pharmacy = Mapper.Map <PharmacyViewModel, Pharmacy.Core.Pharmacy>(pharmacyViewModel); _manager.Add(pharmacy); return(RedirectToAction("Index")); }
public ActionResult Edit(int id, PharmacyViewModel pharmacyViewModel) { if (!ModelState.IsValid) { return(View(pharmacyViewModel)); } var pharmacy = _manager.GetByPrimaryKey(id); pharmacy = Mapper.Map(pharmacyViewModel, pharmacy); _manager.Update(pharmacy); return(RedirectToAction("Index")); }
public ActionResult Edit(int pharmacyId) { var pharmacy = _context.Pharmacies.SingleOrDefault(p => p.Id == pharmacyId); //check if pharmacy exist if (pharmacy == null) { return(HttpNotFound()); } var viewModel = new PharmacyViewModel { Pharmacy = pharmacy }; return(View("PharmacyForm", viewModel)); }
public ActionResult Create(PharmacyViewModel pharmacyView) { if (!ModelState.IsValid) { return(View(pharmacyView)); } try { var pharmacy = Mapper.Map <PharmacyViewModel, Pharmacy>(pharmacyView); _manager.Add(pharmacy); _manager.SaveChanges(); return(RedirectToAction("Index")); } catch { ModelState.AddModelError("", "Ошибка добавления данных"); return(View(pharmacyView)); } }
public async Task <IActionResult> Create(PharmacyViewModel inputModel) { if (!this.ModelState.IsValid) { return(this.View(inputModel)); } var user = await this.userManager.GetUserAsync(this.User); var pharmacyId = await this .pharmaciesService .CreateAsync(inputModel.Name, inputModel.Country, inputModel.Address, inputModel.NewImage, user.Id); if (string.IsNullOrEmpty(pharmacyId)) { return(this.RedirectToAction("Error", "Home")); } this.TempData[Notifications.Key] = Notifications.SuccessfullyCreatedPharmacy; return(this.RedirectToAction("Details", new { id = pharmacyId })); }
public JsonResult SearchPharmacy(string Zipcode, string State) { PharmacyViewModel pvm = new PharmacyViewModel(); pvm.Pharmacies = new List <PharmacyDetails>(); PharmacyDetails pd = new PharmacyDetails(); pd.PharmacyAddress = "Karachi"; pd.PharmacyID = "1"; pd.PharmacyName = "CVS pharmacy"; pvm.Pharmacies.Add(pd); PharmacyDetails pd1 = new PharmacyDetails(); pd1.PharmacyAddress = "Karachi"; pd1.PharmacyID = "1"; pd1.PharmacyName = "Shahi Pharmacy"; pvm.Pharmacies.Add(pd1); return(Json(new { data = pvm }, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(PharmacyViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { _manager.Edit(Mapper.Map <PharmacyViewModel, Pharmacy>(model)); return(RedirectToAction("Index")); } catch (ValidationException exception) { ModelState.AddModelError("", "Validation data error! Please, change values!"); return(View(model)); } catch { ModelState.AddModelError("Name", "Adding data error! Please, try again later!"); return(View(model)); } }
// GET: Pharmacies/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var pharmacy = await _repository.GetByIdAsync(id); if (pharmacy == null) { return(NotFound()); } var viewModel = new PharmacyViewModel() { Pharmacy = pharmacy, MedicalItems = await _mediator.Send(new GetMedItemsListInPharm(pharmacy.PharmId)) }; return(View(viewModel)); }
public ActionResult Edit(PharmacyViewModel pharmacyView) { if (!ModelState.IsValid) { return(View(pharmacyView)); } try { // По другому не получается это сделать :-(((( //var entity = Mapper.Map<PharmacyView, Pharmacy>(pharmacyView); var entity = _manager.GetByPrimaryKey(pharmacyView.Id); entity.Address = pharmacyView.Address; entity.Number = pharmacyView.Number; entity.OpenDate = pharmacyView.OpenDate; entity.PhoneNumber = pharmacyView.PhoneNumber; _manager.SaveChanges(); return(RedirectToAction("Index")); } catch { ModelState.AddModelError("Name", "Возникла какая то ошибка при изменении данных"); return(View(pharmacyView)); } }
public MainWindow() { InitializeComponent(); DataContext = new PharmacyViewModel(); }
public PharmacyPage() { InitializeComponent(); BindingContext = viewModel = new PharmacyViewModel(); }
public IActionResult Create() { var viewModel = new PharmacyViewModel(); return(this.View(viewModel)); }
public ActionResult Pharmacy(PharmacyViewModel pvm, IEnumerable <HttpPostedFileBase> file) { return(Json(new { Sucess = "Saved Sucessfully" })); }