Exemplo n.º 1
0
        public ActionResult AddMedicineCat(int?cat_id)
        {
            var model = new tblMedicineCategory();

            if (cat_id != null)
            {
                model = new MedicineDAL().SingleRecord(Convert.ToInt32(cat_id));
            }
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult AddMedicineCat(int?cat_id, tblMedicineCategory medicineCategory)
        {
            string username = "";

            medicineCategory.isActive = true;

            HttpCookie cookie = HttpContext.Request.Cookies["AdminCookies"];

            if (cookie != null)
            {
                username = Convert.ToString(cookie.Values["UserName"]);
            }

            try
            {
                // TODO: Add insert logic here
                if (cat_id != null)
                {
                    medicineCategory.ID = Convert.ToInt32(cat_id);
                    new MedicineDAL().UpdateRecord(medicineCategory);
                    TempData["AlertTask"] = "medicine updated successfully";
                }
                else
                {
                    medicineCategory.CreatedBy = username;
                    medicineCategory.CreatedAt = DateTime.UtcNow;
                    cat_id = new MedicineDAL().InsertRecord(medicineCategory);
                    TempData["AlertTask"] = "medicine added successfully";
                }

                return(Redirect("/medicine-categories"));
            }
            catch
            {
                return(View());
            }
        }