public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Details,supportType")] request_support request_support)
        {
            if (id != request_support.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(request_support);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!request_supportExists(request_support.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(request_support));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Details,DepartmentId")] Complaint complaint)
        {
            if (id != complaint.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(complaint);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ComplaintExists(complaint.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Departments, "Id", "Id", complaint.DepartmentId);
            return(View(complaint));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Details")] Note note)
        {
            if (id != note.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(note);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NoteExists(note.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(note));
        }
        public async Task <IActionResult> Edit(int id, Events @events)
        {
            if (id != @events.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var fileName = String.Empty;

                string Picture = String.Empty;
                string Photo   = String.Empty;

                // Saving event picture in upload folder
                if (@events.Picture != null)
                {
                    fileName = Guid.NewGuid().ToString() + "_" + @events.Picture.FileName;
                    var path      = "/Content/upload/eventPicture";
                    var uploadDir = Path.Combine(webHostEnvironment.WebRootPath, @".." + path);
                    var imageUrl  = Path.Combine(uploadDir, fileName);
                    using (var fileStream = new FileStream(imageUrl, FileMode.Create))
                    {
                        @events.Picture.CopyTo(fileStream);
                    }
                    Picture = path + '/' + fileName;
                }

                // saving event photo in upload folder
                if (@events.Photo != null)
                {
                    fileName = Guid.NewGuid().ToString() + "_" + @events.Photo.FileName;
                    var path      = "/Content/upload/eventPhoto";
                    var uploadDir = Path.Combine(webHostEnvironment.WebRootPath, @".." + path);
                    var imageUrl  = Path.Combine(uploadDir, fileName);
                    using (var fileStream = new FileStream(imageUrl, FileMode.Create))
                    {
                        @events.Photo.CopyTo(fileStream);
                    }
                    Photo = path + '/' + fileName;
                }


                // Model data to update event
                var @event = new Event
                {
                    Id                = @events.Id,
                    Name              = @events.Name,
                    Detail            = @events.Detail,
                    Picture           = !String.IsNullOrEmpty(Picture) ? Picture : @events.PicturePath,
                    Photo             = !String.IsNullOrEmpty(Photo) ? Photo : @events.PhotoPath,
                    Requirement       = @events.Requirement,
                    Time              = @events.Time,
                    Location          = @events.Location,
                    ParticipationIcon = @events.ParticipationIcon,
                    ISsetlimited      = @events.ISsetlimited,
                    Setlimited        = @events.Setlimited,
                    IsNeedApproval    = @events.IsNeedApproval,
                    StartDate         = @events.StartDate,
                    EndDate           = @events.EndDate,
                    CategoryId        = @events.CategoryId
                };

                try
                {
                    _context.Update(@event);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventExists(@event.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", @events.CategoryId);
            //ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", @events.CategoryId);
            ViewData["CategoryList"] = _context.Categories.Select(c => new SelectListItem
            {
                Text     = c.CategoryName,
                Value    = Convert.ToString(c.Id),
                Selected = (Convert.ToInt32(@events.CategoryId) == c.Id) ? true : false
            });
            return(View(@events));
        }