public HttpResponseMessage Save(User_Followed_User usr)
        {
            bool SuccesfullSaved = UsuariosSeguidosHelper.Save(usr);

            if (!SuccesfullSaved)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(Request.CreateResponse(HttpStatusCode.Created));
        }
        public HttpResponseMessage GetUserFollowedById(int UserId)
        {
            if (!UsuariosSeguidosHelper.IsFollowingUsers(UserId))
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            User_Followed_User usr = UsuariosSeguidosHelper.GetUserFollowedByPrimaryKey(UserId);

            return(Request.CreateResponse(HttpStatusCode.OK, usr));
        }
Esempio n. 3
0
        public static USER_FOLLOWED_USER ToTable(this User_Followed_User Model)
        {
            if (Model == null)
            {
                return(null);
            }

            return(new USER_FOLLOWED_USER()
            {
                UserID = Model.UserID,
                UserIdFollowed = Model.UserIdFollowed,
                Fecha_Creacion = Model.Fecha_Creacion
            });
        }
Esempio n. 4
0
        public static User_Followed_User GetUserFollowedByPrimaryKey(int UserId)
        {
            User_Followed_User result = new User_Followed_User();

            using (HelpDeskApfEntities context = new HelpDeskApfEntities())
            {
                var queryResult = context.USER_FOLLOWED_USER.SingleOrDefault(x => x.UserID == UserId);

                if (queryResult != null)
                {
                    result = queryResult.ToModel();
                }
            }

            return(result);
        }
        /// <summary>
        /// Converts this instance of <see cref="USER_FOLLOWED_USER"/> to an instance of <see cref="User_Followed_User"/>.
        /// </summary>
        /// <param name="entity"><see cref="USER_FOLLOWED_USER"/> to convert.</param>
        public static User_Followed_User ToModel(this USER_FOLLOWED_USER entity)
        {
            if (entity == null)
            {
                return(new User_Followed_User());
            }

            var dto = new User_Followed_User();

            dto.UserID         = entity.UserID;
            dto.UserIdFollowed = entity.UserIdFollowed;
            dto.Fecha_Creacion = entity.Fecha_Creacion;

            entity.OnDTO(dto);

            return(dto);
        }
        /// <summary>
        /// Converts this instance of <see cref="User_Followed_User"/> to an instance of <see cref="USER_FOLLOWED_USER"/>.
        /// </summary>
        /// <param name="dto"><see cref="User_Followed_User"/> to convert.</param>
        public static USER_FOLLOWED_USER ToTable(this User_Followed_User dto)
        {
            if (dto == null)
            {
                return(null);
            }

            var entity = new USER_FOLLOWED_USER();

            entity.UserID         = dto.UserID;
            entity.UserIdFollowed = dto.UserIdFollowed;
            entity.Fecha_Creacion = dto.Fecha_Creacion;

            dto.OnEntity(entity);

            return(entity);
        }
        public static bool Save(User_Followed_User model)
        {
            bool result;

            using (HelpDeskApfEntities context = new HelpDeskApfEntities())
            {
                try
                {
                    context.USER_FOLLOWED_USER.Add(model.ToTable());
                    context.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    result = false;
                }
            }

            return(result);
        }
 /// <summary>
 /// Invoked when <see cref="ToTable"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="USER_FOLLOWED_USER"/> converted from <see cref="User_Followed_User"/>.</param>
 static partial void OnEntity(this User_Followed_User dto, USER_FOLLOWED_USER entity);
 /// <summary>
 /// Invoked when <see cref="ToModel"/> operation is about to return.
 /// </summary>
 /// <param name="dto"><see cref="User_Followed_User"/> converted from <see cref="USER_FOLLOWED_USER"/>.</param>
 static partial void OnDTO(this USER_FOLLOWED_USER entity, User_Followed_User dto);