コード例 #1
0
        public ActionResult Create()
        {
            ViewData["SelectedList"]     = new SelectedListHelpers().GetSelectedList(_dbCategory.Get());
            ViewData["SelectedListUnit"] = new SelectedListHelpers().GetSelectedList(_unit.Get());

            return(View());
        }
コード例 #2
0
        public ActionResult Create()
        {
            ViewData["SelectedListForTypeOfOffer"] = new SelectedListHelpers().GetSelectedList(_iTypeOfOffer.Get());
            ViewData["SelectedListForProblem"]     = new SelectedListHelpers().GetSelectedList(_iProblem.Get());
            //ViewData["SelectedListForStatus"] = new SelectedListHelpers().GetSelectedList(_iStatus.Get());
            ViewData["SelectedListForDirection"] = new SelectedListHelpers().GetSelectedList(_iDirection.Get());

            return(View());
        }
コード例 #3
0
        public async Task <ActionResult> UserRolesControl(AspNetUserDto value)
        {
            ViewData["SelectedListForRoles"] = new SelectedListHelpers().GetSelectedList(_iAspNetRole.GetAspNetRoles());
            ViewData["UserId"] = value.Id;

            return(View(await _iAspNetUserRoles.Get(new AspNetUserRolesDto {
                UserId = value.Id
            })));
        }
コード例 #4
0
        public async Task <ActionResult> EditType(OfferDto value, int FilesId = 0)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (value.FileContent != null)
                    {
                        List <FileDto> files = new List <FileDto>();

                        foreach (var image in value.FileContent)
                        {
                            using (var br = new BinaryReader(image.InputStream))
                            {
                                FileDto fileDto = new FileDto
                                {
                                    FileContent = br.ReadBytes(image.ContentLength),
                                    FileName    = image.FileName,
                                    ContentType = image.ContentType,
                                    OfferId     = value.Id,
                                    Id          = FilesId
                                };
                                files.Add(fileDto);
                            }
                        }
                        value.Files = files;
                    }

                    value.UserId     = _users.GetAspNetUsers().ToList().Where(u => u.UserName == User.Identity.GetUserName()).First().Id;
                    value.StatusesId = 2;

                    await db.Update(value);

                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewData["SelectedListForTypeOfOffer"] = new SelectedListHelpers().GetSelectedList(_iTypeOfOffer.Get());
                    ViewData["SelectedListForProblem"]     = new SelectedListHelpers().GetSelectedList(_iProblem.Get());
                    //ViewData["SelectedListForStatus"] = new SelectedListHelpers().GetSelectedList(_iStatus.Get());
                    ViewData["SelectedListForDirection"] = new SelectedListHelpers().GetSelectedList(_iDirection.Get());
                }
            }
            catch
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return(View(value));
        }
コード例 #5
0
        public async Task <ActionResult> EditType(ProblemDto value)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await db.Update(value);

                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                ViewData["SelectedList"] = new SelectedListHelpers().GetSelectedList(_dbCategory.Get());
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return(View(value));
        }
コード例 #6
0
 public async Task <ActionResult> DeleteRole(AspNetUserRolesDto value)
 {
     ViewData["SelectedListForRoles"] = new SelectedListHelpers().GetSelectedList(_iAspNetRole.GetAspNetRoles());
     try
     {
         if (ModelState.IsValid)
         {
             await _iAspNetUserRoles.Delete(value);
         }
     }
     catch
     {
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return(RedirectToAction("UserRolesControl", new AspNetUserDto {
         Id = value.UserId
     }));
 }
コード例 #7
0
        public ActionResult Edit(int id)
        {
            ViewData["SelectedList"] = new SelectedListHelpers().GetSelectedList(_dbCategory.Get());

            return(View(db.Get(id)));
        }
コード例 #8
0
        public ActionResult Index(int?page)
        {
            ViewData["SelectedList"] = new SelectedListHelpers().GetSelectedList(_dbCategory.Get());

            return(View(db.Get().ToPagedList(page ?? 1, 10)));
        }