示例#1
0
        public ActionResult Create(TreatmentPlaceViewModel model)
        {
            string username = User.Identity.Name;
            string userid   = ((ClaimsPrincipal)User).Claims?.Where(c => c.Type == ClaimTypes.GroupSid).FirstOrDefault()?.Value ?? "";

            JohaMeriSQL1Entities db = new JohaMeriSQL1Entities();

            TreatmentPlace trp = new TreatmentPlace();

            trp.TreatmentPlaceName   = model.TreatmentPlaceName;
            trp.TreatmentPlaceNumber = model.TreatmentPlaceNumber;

            db.TreatmentPlace.Add(trp);

            try
            {
                db.SaveChanges();
            }

            catch (Exception ex)
            {
            }

            return(RedirectToAction("Index"));
        }
        // GET: TreatmentPlaces
        public ActionResult Index()
        {
            //string username = User.Identity.Name;
            //string userid = ((ClaimsPrincipal)User).Claims?.Where(c => c.Type == ClaimTypes.GroupSid).FirstOrDefault()?.Value ?? "";

            List <TreatmentPlaceViewModel> model = new List <TreatmentPlaceViewModel>();

            JohaMeriSQL1Entities entities = new JohaMeriSQL1Entities();

            try
            {
                List <TreatmentPlace> treatplaces = entities.TreatmentPlace.ToList();
                // muodostetaan näkymämalli tietokannan rivien pohjalta
                foreach (TreatmentPlace treatplace in treatplaces)
                {
                    TreatmentPlaceViewModel view = new TreatmentPlaceViewModel();
                    view.TreatmentPlace_id    = treatplace.TreatmentPlace_id;
                    view.TreatmentPlaceName   = treatplace.TreatmentPlaceName;
                    view.TreatmentPlaceNumber = treatplace.TreatmentPlaceNumber;

                    model.Add(view);
                }
            }
            finally
            {
                entities.Dispose();
            }

            return(View(model));
        }//Index
        }//Index

        // GET: TreatmentPlaces/Details/5
        //public ActionResult Details(int? id)
        //{
        //    TreatmentPlaceViewModel model = new TreatmentPlaceViewModel();

        //    JohaMeriSQL1Entities entities = new JohaMeriSQL1Entities();
        //    try
        //    {
        //        if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    TreatmentPlace treatmentPlace = db.TreatmentPlace.Find(id);
        //    if (treatmentPlace == null)
        //    {
        //        return HttpNotFound();
        //    }

        //        // muodostetaan näkymämalli tietokannan rivien pohjalta
        //        TreatmentPlaceViewModel view = new TreatmentPlaceViewModel();
        //        view.TreatmentPlace_id = treatmentPlace.TreatmentPlace_id;
        //        view.TreatmentPlaceName = treatmentPlace.TreatmentPlaceName;
        //        view.TreatmentPlaceNumber = treatmentPlace.TreatmentPlaceNumber;

        //        model = view;
        //    }
        //    finally
        //    {
        //        entities.Dispose();
        //    }

        //    return View(model);
        //}//details


        // GET: TreatmentPlaces/Create
        public ActionResult Create()
        {
            JohaMeriSQL1Entities db = new JohaMeriSQL1Entities();

            TreatmentPlaceViewModel model = new TreatmentPlaceViewModel();

            return(View(model));
        }//create
        public ActionResult Edit(TreatmentPlaceViewModel model)
        {
            TreatmentPlace treatplace = db.TreatmentPlace.Find(model.TreatmentPlace_id);

            treatplace.TreatmentPlaceName   = model.TreatmentPlaceName;
            treatplace.TreatmentPlaceNumber = model.TreatmentPlaceNumber;

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }//edit
示例#5
0
        }//Index

        // GET: TreatmentPlaces/Details/5
        //public ActionResult Details(int? id)
        //{
        //    TreatmentPlaceViewModel model = new TreatmentPlaceViewModel();

        //    JohaMeriSQL1Entities entities = new JohaMeriSQL1Entities();
        //    try
        //    {
        //        if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    TreatmentPlace treatmentPlace = db.TreatmentPlace.Find(id);
        //    if (treatmentPlace == null)
        //    {
        //        return HttpNotFound();
        //    }

        //        // muodostetaan näkymämalli tietokannan rivien pohjalta
        //        TreatmentPlaceViewModel view = new TreatmentPlaceViewModel();
        //        view.TreatmentPlace_id = treatmentPlace.TreatmentPlace_id;
        //        view.TreatmentPlaceName = treatmentPlace.TreatmentPlaceName;
        //        view.TreatmentPlaceNumber = treatmentPlace.TreatmentPlaceNumber;

        //        model = view;
        //    }
        //    finally
        //    {
        //        entities.Dispose();
        //    }

        //    return View(model);
        //}//details


        // GET: TreatmentPlaces/Create
        public ActionResult Create()
        {
            string username = User.Identity.Name;
            string userid   = ((ClaimsPrincipal)User).Claims?.Where(c => c.Type == ClaimTypes.GroupSid).FirstOrDefault()?.Value ?? "";

            JohaMeriSQL1Entities db = new JohaMeriSQL1Entities();

            TreatmentPlaceViewModel model = new TreatmentPlaceViewModel();

            return(View(model));
        }//create
示例#6
0
        public ActionResult Edit(TreatmentPlaceViewModel model)
        {
            string username = User.Identity.Name;
            string userid   = ((ClaimsPrincipal)User).Claims?.Where(c => c.Type == ClaimTypes.GroupSid).FirstOrDefault()?.Value ?? "";

            TreatmentPlace treatplace = db.TreatmentPlace.Find(model.TreatmentPlace_id);

            treatplace.TreatmentPlaceName   = model.TreatmentPlaceName;
            treatplace.TreatmentPlaceNumber = model.TreatmentPlaceNumber;

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }//edit
        }//edit

        // GET: TreatmentPlaces/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TreatmentPlace treatmentPlace = db.TreatmentPlace.Find(id);

            if (treatmentPlace == null)
            {
                return(HttpNotFound());
            }

            TreatmentPlaceViewModel view = new TreatmentPlaceViewModel();

            view.TreatmentPlace_id    = treatmentPlace.TreatmentPlace_id;
            view.TreatmentPlaceName   = treatmentPlace.TreatmentPlaceName;
            view.TreatmentPlaceNumber = treatmentPlace.TreatmentPlaceNumber;

            return(View(view));
        }//Delete
        // GET: TreatmentPlaces/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TreatmentPlace treatmentPlace = db.TreatmentPlace.Find(id);

            if (treatmentPlace == null)
            {
                return(HttpNotFound());
            }

            TreatmentPlaceViewModel treatplace = new TreatmentPlaceViewModel();

            treatplace.TreatmentPlace_id    = treatmentPlace.TreatmentPlace_id;
            treatplace.TreatmentPlaceName   = treatmentPlace.TreatmentPlaceName;
            treatplace.TreatmentPlaceNumber = treatmentPlace.TreatmentPlaceNumber;

            return(View(treatplace));
        }
        public ActionResult Create(TreatmentPlaceViewModel model)
        {
            JohaMeriSQL1Entities db = new JohaMeriSQL1Entities();

            TreatmentPlace trp = new TreatmentPlace();

            trp.TreatmentPlaceName   = model.TreatmentPlaceName;
            trp.TreatmentPlaceNumber = model.TreatmentPlaceNumber;

            db.TreatmentPlace.Add(trp);

            try
            {
                db.SaveChanges();
            }

            catch (Exception ex)
            {
            }

            return(RedirectToAction("Index"));
        }
示例#10
0
        }//edit

        // GET: TreatmentPlaces/Delete/5
        public ActionResult Delete(int?id)
        {
            string username = User.Identity.Name;
            string userid   = ((ClaimsPrincipal)User).Claims?.Where(c => c.Type == ClaimTypes.GroupSid).FirstOrDefault()?.Value ?? "";

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TreatmentPlace treatmentPlace = db.TreatmentPlace.Find(id);

            if (treatmentPlace == null)
            {
                return(HttpNotFound());
            }

            TreatmentPlaceViewModel view = new TreatmentPlaceViewModel();

            view.TreatmentPlace_id    = treatmentPlace.TreatmentPlace_id;
            view.TreatmentPlaceName   = treatmentPlace.TreatmentPlaceName;
            view.TreatmentPlaceNumber = treatmentPlace.TreatmentPlaceNumber;

            return(View(view));
        }//Delete