Esempio n. 1
0
        public ActionResult Create(FormCollection collection)//[Bind(Include = "ID,Ndc,Name,Producer,MImage,GenericName,ActiveIngredients,Properties")] MedicineViewModel medicineViewModel)
        {
            try {
                DetailsViewModel   DescriptionList = new DetailsViewModel();
                ImageValidateLogic bl       = new ImageValidateLogic();
                string             filePath = Server.MapPath(Url.Content($"~/images/{collection["MImage"].ToString()}"));
                DescriptionList.Descriptions = new List <string>(bl.CheckImage(filePath));
                DrugAdminLogic bl2 = new DrugAdminLogic();

                bl2.AddDrug(collection["Name"], collection["GenericName"], collection["Producer"], collection["ActiveIngredients"], collection["Properties"], collection["MImage"].ToString(), collection["Ndc"]);

                ViewBag.Message = String.Format("The medicine was added successfully.");
                return(View("Home"));// RedirectToAction("Home");
            }
            catch (Exception ex)
            {
                if (ex.Message == "The medicine already exists in the system")
                {
                    ViewBag.Message = String.Format("The medicine already exists in the system , try again");
                }

                if (ex.Message == "not a drug image")
                {
                    ViewBag.Message = String.Format("The image that you selected is not a medicine , try again");
                }


                return(View());
            }
        }
Esempio n. 2
0
        public ActionResult Edit(FormCollection collection)//[Bind(Include = "ID,Ndc,Name,Producer,MImage,GenericName,ActiveIngredients,Properties")] MedicineViewModel medicineViewModel)
        {
            try {
                DrugAdminLogic bl2 = new DrugAdminLogic();
                if (collection["MImage"] == string.Empty)
                {
                    bl2.EditDrug(collection["Name"], collection["GenericName"], collection["Producer"], collection["ActiveIngredients"], collection["Properties"], null, collection["Ndc"]);
                }
                else
                {
                    DetailsViewModel   DescriptionList = new DetailsViewModel();
                    ImageValidateLogic bl       = new ImageValidateLogic();
                    string             filePath = "C:\\Users\\מירי\\Downloads\\Gui_\\Gui_\\images\\" + collection["MImage"];// Server.MapPath(Url.Content($"{ collection["MImage"].ToString()}"));
                    DescriptionList.Descriptions = new List <string>(bl.CheckImage(filePath));
                    bl2.EditDrug(collection["Name"], collection["GenericName"], collection["Producer"], collection["ActiveIngredients"], collection["Properties"], collection["MImage"], collection["Ndc"]);
                }
                ViewBag.Message = String.Format("The medicine was edited successfully.");
                return(View("Home"));
            }
            catch (Exception ex)
            {
                if (ex.Message == "not a drug image")
                {
                    ViewBag.Message = String.Format("The image that you selected is not a medicine , try again");
                }


                return(View());
            }
        }
Esempio n. 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            DrugAdminLogic bl = new DrugAdminLogic();

            bl.deleteDrug(id);
            ViewBag.Message = String.Format("The medicine was deleted successfully.");
            return(View("Home"));
        }
Esempio n. 4
0
        public static MvcHtmlString DropDownListForUsers(this HtmlHelper htmlHelper, string name)
        {
            DrugAdminLogic bl      = new DrugAdminLogic();
            string         options = "";

            foreach (var user in bl.listMedicine())
            {
                options += $"<option value ='{user.Name}'> {user.Name} </option>";
            }
            return(new MvcHtmlString($"<select  name={name} style='color:black'>{options}</select>"));
        }