Exemple #1
0
        public ActionResult AddHospital(int?Hospital_id, tblHospital hospital)
        {
            string     username = "";
            HttpCookie cookie   = HttpContext.Request.Cookies["AdminCookies"];

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

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

                return(Redirect("/hospitals"));
            }
            catch
            {
                return(View());
            }
        }
Exemple #2
0
        // GET: Hospital/Create
        public ActionResult AddHospital(int?Hospital_id)
        {
            var model = new tblHospital();

            if (Hospital_id != null)
            {
                model = new HospitalDAL().SingleRecord(Convert.ToInt32(Hospital_id));
            }
            return(View(model));
        }