Ejemplo n.º 1
0
        public async Task <ActionResult> Edit([Bind(Include = "ResourceId,EntryMade,PersonId,Description,StartOfAvailability,EndOfAvailability,Location,Qty,Status,DisasterId,ResourceTypeId")] Resource resource)
        {
            if (resource.Status == ResourceStatus.All)
            {
                ModelState.AddModelError("Status", "You must select a status other than 'All'.");
            }

            if (resource.StartOfAvailability > resource.EndOfAvailability)
            {
                ModelState.AddModelError("StartOfAvailability", "The start of the availability for this resource cannot be after the end of its availability.");
            }

            if (ModelState.IsValid)
            {
                db.Entry(resource).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.DisasterId     = new SelectList(db.Disasters, "Id", "Name", resource.DisasterId);
            ViewBag.PersonId       = new SelectList(db.Persons, "Id", "FirstName", resource.PersonId);
            ViewBag.ResourceTypeId = new SelectList(db.ResourceTypes, "ResourceTypeId", "TypeName", resource.ResourceTypeId);
            return(View(resource));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Edit([Bind(Include = "RequestId,CreatedDate,EndDate,Description,OrganizationId,CreatorId,Completed,Location")] Request request)
        {
            if (ModelState.IsValid)
            {
                db.Entry(request).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.CreatorId = new SelectList(db.Persons, "Id", "FirstName", request.CreatorId);
            return(View(request));
        }