Example #1
0
        public async Task <ActionResult> AddGroupEvent(AddEditGroupEventViewModel model)
        {
            if (model.AppID != 0)
            {
                model.GroupEvent.AddProduct(siteService.GetProductByAppID(model.AppID));
            }
            else if (String.IsNullOrEmpty(model.Product.ProductName) == false)
            {
                model.GroupEvent.AddProduct(model.Product);
            }
            else if (model.GroupEvent?.ProductID != 0)
            {
                model.GroupEvent.AddProduct(siteService.GetProductByID((int)model.GroupEvent.ProductID));
            }

            model.GroupEvent.AppUser = await siteService.GetAppUserByID(model.GroupEvent.AppUserID);

            model.LoggedInUser = await siteService.GetCurrentUser();

            model.FullNavList = CreateHomeAdminNavList();

            if (ModelState.IsValid)
            {
                siteService.AddGroupEvent(model.GroupEvent);
            }
            else
            {
                return(View(model));
            }

            model.GroupEvent = siteService.GetGroupEventByID(model.GroupEvent.GroupEventID);

            return(View("EditGroupEvent", model));
        }