private static void ValidateGroupExistence(UpdateGroupRequest request, Entity.Group currentGroup)
 {
     if (currentGroup == null)
     {
         throw new Exception("There is not any group with this GroupId : " + request);
     }
 }
        private static void SetNewValues(UpdateGroupRequest request, Entity.Group currentGroup)
        {
            if (!string.IsNullOrEmpty(request.Model.Description))
            {
                currentGroup.Description = request.Model.Description;
            }

            if (!string.IsNullOrEmpty(request.Model.ImageUrl))
            {
                currentGroup.ImageUrl = request.Model.ImageUrl;
            }

            if (!string.IsNullOrEmpty(request.Model.LatinName))
            {
                currentGroup.LatinName = request.Model.LatinName;
            }

            if (!string.IsNullOrEmpty(request.Model.Name))
            {
                currentGroup.Name = request.Model.Name;
            }
        }
Beispiel #3
0
        public ActionResult CreateGroup(string Token, string Title, string Description, int JoinMethod)
        {
            var user = CheckUser(Token);

            if (user == null)
            {
                return(Json(new Base
                {
                    Code = 500,
                    IsSuccess = false,
                    Info = "AccessToken不正确"
                }));
            }
            var group = new Entity.Group
            {
                Title           = Title,
                Description     = Description,
                Icon            = null,
                JoinMethodAsInt = JoinMethod
            };

            DbContext.Groups.Add(group);
            DbContext.GroupMembers.Add(new Entity.GroupMember
            {
                GroupID  = group.ID,
                JoinTime = DateTime.Now,
                Role     = Entity.GroupRole.Root,
                UserID   = user.ID
            });
            DbContext.SaveChanges();
            return(Json(new Base
            {
                Code = 0,
                IsSuccess = true,
                Info = ""
            }));
        }
Beispiel #4
0
 public CreateNewGroupRequest(Entity.Group model)
 {
     Model = model;
 }
Beispiel #5
0
 public ActionResult CreateGroup(string Token, string Title, string Description, int JoinMethod)
 {
     var user = CheckUser(Token);
     if (user == null)
         return Json(new Base
         {
             Code = 500,
             IsSuccess = false,
             Info = "AccessToken不正确"
         });
     var group = new Entity.Group
     {
         Title = Title,
         Description = Description,
         Icon = null,
         JoinMethodAsInt = JoinMethod
     };
     DbContext.Groups.Add(group);
     DbContext.GroupMembers.Add(new Entity.GroupMember
     {
         GroupID = group.ID,
         JoinTime = DateTime.Now,
         Role = Entity.GroupRole.Root,
         UserID = user.ID
     });
     DbContext.SaveChanges();
     return Json(new Base
     {
         Code = 0,
         IsSuccess = true,
         Info = ""
     });
 }