public ActionResult NewPharmacy()
        {
            var viewModel = new PharmacyViewModel {
            };

            return(View("PharmacyForm", viewModel));
        }
Exemple #2
0
        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"));
        }
Exemple #3
0
        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));
        }
Exemple #5
0
 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));
     }
 }
Exemple #6
0
        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 }));
        }
Exemple #7
0
        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));
        }
Exemple #8
0
 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));
        }
Exemple #10
0
 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));
     }
 }
Exemple #11
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = new PharmacyViewModel();
        }
Exemple #12
0
 public PharmacyPage()
 {
     InitializeComponent();
     BindingContext = viewModel = new PharmacyViewModel();
 }
Exemple #13
0
        public IActionResult Create()
        {
            var viewModel = new PharmacyViewModel();

            return(this.View(viewModel));
        }
Exemple #14
0
 public ActionResult Pharmacy(PharmacyViewModel pvm, IEnumerable <HttpPostedFileBase> file)
 {
     return(Json(new { Sucess = "Saved Sucessfully" }));
 }