Beispiel #1
0
        public async Task <IActionResult> Edit(Int32?id, WardEditModel model)
        {
            if (id == null)
            {
                return(this.NotFound());
            }

            var ward = await this.context.Wards
                       .Include(x => x.Hospital)
                       .SingleOrDefaultAsync(m => m.Id == id);

            if (ward == null)
            {
                return(this.NotFound());
            }

            if (this.ModelState.IsValid)
            {
                ward.Name = model.Name;
                await this.context.SaveChangesAsync();

                return(this.RedirectToAction("Index", new { hospitalId = ward.HospitalId }));
            }
            this.ViewBag.Ward = ward;
            return(this.View(model));
        }
        // GET: Wards/Edit/5
        public async Task <IActionResult> Edit(Int32?id, Int32?hospitalId)
        {
            if (id == null)
            {
                return(this.NotFound());
            }

            var ward = await this.context.Wards.SingleOrDefaultAsync(m => m.WardId == id);

            if (ward == null)
            {
                return(this.NotFound());
            }

            if (hospitalId == null)
            {
                return(this.NotFound());
            }

            var hospital = await this.context.Hospitals
                           .SingleOrDefaultAsync(x => x.Id == hospitalId);

            if (hospital == null)
            {
                return(this.NotFound());
            }

            this.ViewBag.Hospital = hospital;

            var model = new WardEditModel
            {
                Name = ward.Name
            };

            if (hospitalId == null)
            {
                return(this.NotFound());
            }

            var hospital = await this.context.Hospitals
                           .SingleOrDefaultAsync(x => x.Id == hospitalId);

            if (hospital == null)
            {
                return(this.NotFound());
            }

            this.ViewBag.Hospital = hospital;
            return(this.View(model));
        }
        // GET: Wards/Edit/5
        public async Task <IActionResult> Edit(Int32?id)
        {
            if (id == null)
            {
                return(this.NotFound());
            }

            var ward = await this.context.Wards.SingleOrDefaultAsync(m => m.Id == id);

            if (ward == null)
            {
                return(this.NotFound());
            }

            var model = new WardEditModel
            {
                Name = ward.Name
            };

            return(this.View(model));
        }