public HttpResponseMessage EditGroup(SocialGroup editedUser)
 {
     try
     {
         //var dataUser = UserMapper.Map(newUser);
         //var idsOfAffinities = newUser.AffinityTypes.Select(x => x.Id).ToList<int>();
         editedUser.Password = sha256_hash(editedUser.Password);
         groupsRepository.EditUser(editedUser);
         var response = this.Request.CreateResponse(HttpStatusCode.Created, true);
         return response;
     }
     catch (Exception e)
     {
         var response = this.Request.CreateResponse(HttpStatusCode.BadRequest, new HttpError(e.ToString()));
         return response;
     }
 }
 public bool AddNewGroup(SocialGroup socGroup)
 {
     using (var context = new JoinINN.Infrastructure.GroupsDb())
     {
         try
         {
             socGroup.AffinityType = context.AffinityTypes.FirstOrDefault(x => x.Id == socGroup.AffinityType_Id);
             socGroup.City = context.Cities.FirstOrDefault(x => x.Id == socGroup.CityId);
             context.SocialGroups.Add(socGroup);
             context.SaveChanges();
             return true;
         }
         catch (DbEntityValidationException dbEx)
         {
             return false;
         }
     }
 }
        public void EditUser(SocialGroup socGroup)
        {
            using (var context = new JoinINN.Infrastructure.GroupsDb())
            {
                try
                {
                    var existingSocGroup = context.SocialGroups.FirstOrDefault(x => x.Id == socGroup.Id);

                    existingSocGroup.AffinityType = context.AffinityTypes.FirstOrDefault(x => x.Id == socGroup.AffinityType_Id);
                    existingSocGroup.Password = socGroup.Password;
                    existingSocGroup.Name = socGroup.Name;
                    existingSocGroup.OfficialWebUrl = socGroup.OfficialWebUrl;
                    existingSocGroup.FacebookPageUrl = socGroup.FacebookPageUrl;
                    existingSocGroup.photoUrl = socGroup.photoUrl;
                    existingSocGroup.ContactNumber = socGroup.ContactNumber;
                    existingSocGroup.Description = socGroup.Description;

                    context.SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                }
            }
        }