public bool CreateMasterGroup(MasterGroupCreate model, string username)
 {
     //var user = ctx.Users.Single(e => e.Id == _userID.ToString());
     using (var ctx = new ApplicationDbContext())
     {
         var entity = new MasterGroup.Data.MasterGroup()
         {
             OwnerId     = _userID,
             Subject     = model.Subject,
             Username    = username,
             Name        = model.Name,
             Description = model.Description,
             CheckItem1  = model.Commitment1,
             CheckItem2  = model.Commitment2,
             CheckItem3  = model.Commitment3,
             CreatedUtc  = DateTimeOffset.UtcNow
         };
         ctx.MGroups.Add(entity);
         ctx.SaveChanges();
         entity.ListId = entity.GroupId;
         entity.Quese  = new GroupCheckLists
         {
             Check1 = model.Check1,
             Check2 = model.Check2,
             Check3 = model.Check3
         };
         return(ctx.SaveChanges() == 2);
     }
 }
Exemple #2
0
        public ActionResult Create(MasterGroupCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));                     //if its wrong then return the view so they can fix it
            }
            var service = CreateMasterGroupService();

            //if its right step out of this loop interact with the service layer and create a new group model that is linked to their profile.

            if (service.CreateMasterGroup(model, User.Identity.Name))
            {
                TempData["SaveResult"] = "Your Group was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Group could not be created.");

            return(View(model));
        }