예제 #1
0
        // GET: Teams/Create
        public ActionResult Create()
        {
            TeamCreateViewModel teamCreateViewModel = new TeamCreateViewModel();
            var entryList = new List <EntryDropDownListViewModel>();

            var mapperConfig = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <EntryDTO, EntryDropDownListViewModel>();
            });

            using (var entryService = new EntryService())
            {
                try
                {
                    var user        = SessionLoginUtilities.GetLoggedInUser(Session);
                    var allEntryDto = user.Permissions.GetEntryAdminPermissons <EntryDTO>();
                    if (allEntryDto == null)
                    {
                        throw new NullReferenceException();
                    }
                    var mapper = mapperConfig.CreateMapper();
                    mapper.Map(allEntryDto, entryList);

                    ViewBag.EntryDropDownList = new SelectList(entryList.OrderBy(b => b.FullEntryName), "Id", "FullEntryName");

                    return(View());
                }
                catch (Exception e)
                {
                    TempData["ResultMessage"] = e.Message;
                    return(View("Error"));
                }
            }
        }
예제 #2
0
 public ActionResult Create(TeamCreateViewModel teamCreateViewModel)
 {
     try
     {
         TeamDTO teamDto = new TeamDTO(teamCreateViewModel.TeamNo, teamCreateViewModel.TeamName, teamCreateViewModel.EntryId);
         var     user    = SessionLoginUtilities.GetLoggedInUser(Session);
         using (var teamService = new TeamService())
         {
             teamService.EagerDisconnectedService.Add(user, teamDto);
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         TempData["ResultMessage"] = e.Message;
         return(View("Error"));
     }
 }