Exemple #1
0
        public bool Add(FriendRelationshipViewModel model)
        {
            model.Id = Guid.NewGuid().ToString();
            FriendRelationship entity = new FriendRelationship();

            uow.Set <FriendRelationship>().Add(entity);
            entity.Id     = model.Id;
            entity.User   = model.User == null ? null : uow.Set <ApplicationUser>().Find(model.User.Id);
            entity.Owner  = model.Owner == null ? null : uow.Set <ApplicationUser>().Find(model.Owner.Id);
            entity.Status = (FriendRelationshipStatusEnum)model.Status;
            uow.Commit();
            return(true);
        }
Exemple #2
0
        public bool Update(FriendRelationshipViewModel model)
        {
            var entity = uow.Set <FriendRelationship>().Find(model.Id);

            if (entity == null)
            {
                return(false);
            }
            entity.Id     = model.Id;
            entity.User   = model.User == null ? null : uow.Set <ApplicationUser>().Find(model.User.Id);
            entity.Owner  = model.Owner == null ? null : uow.Set <ApplicationUser>().Find(model.Owner.Id);
            entity.Status = (FriendRelationshipStatusEnum)model.Status;
            uow.Commit();
            return(true);
        }