コード例 #1
0
 public void CreateGroup(string username, EPGroup newGroup)
 {
     using (var db = new EPContext())
     {
         var tempUser = db.Users.FirstOrDefault(u => u.Username == username);
         newGroup.Name = newGroup.Name + "$" + username + "_" + Guid.NewGuid().ToString() + "_G";
         db.Entry(tempUser).Collection(p => p.Calendars).Load();
         var newEntry = new EPEntry(tempUser, newGroup, tempUser.Calendars.Count);
         tempUser.Calendars.Add(newEntry);
         newGroup.Entryes.Add(newEntry);
         db.SaveChanges();
     }
 }
コード例 #2
0
        public ActionResult CreateGroup(CreateGroupViewModel model)
        {
            if (ModelState.IsValid)
            {
                EPGroup tempGroup = new EPGroup();
                tempGroup.Name = model.Name;
                _service.CreateGroup(User.Identity.Name, tempGroup);
                return RedirectToAction("Index");
            }
            else
            {
                //TODO add other errors
                ViewData["Error"] = "Invalid group name. Group name must be atleast 1 and no more than 10 characters long.";

                return View();
            }
        }