Example #1
0
        public ModelAPI.DTO.Contact Insert(ModelAPI.Command.ContactNew command)
        {
            var user = GetLoggedUser();
            var data = new Repository.Contact(Context, user).Insert(user.Id, command.ToModel());

            return(new Converter.Contact(Context).To(user.Id, data.Id));
        }
Example #2
0
        public List <ModelAPI.DTO.Contact> GetList(Model.Enums.ContactSort?sort, bool?sortAscending, int?page, int?pageLenght)
        {
            var user = GetLoggedUser();
            var ids  = new Repository.Contact(Context, user).GetIdsByUserId(user.Id);

            return(new Converter.Contact(Context).To(user.Id, ids, sort, sortAscending, page, pageLenght));
        }
Example #3
0
        public ModelAPI.DTO.Contact UpdateName(int contactId, string value)
        {
            var user = GetLoggedUser();

            if (!new Security.Contact(Context).UserCanEdit(user.Id, contactId))
            {
                ErrorSecurity();
            }

            var data = new Repository.Contact(Context, user).UpdateName(user.Id, contactId, value);

            return(new Converter.Contact(Context).To(user.Id, data.Id));
        }
Example #4
0
        public ModelAPI.DTO.Contact GetById(int id)
        {
            var user = GetLoggedUser();

            if (!new Security.Contact(Context).UserCanRead(user.Id, id))
            {
                ErrorSecurity();
            }

            var data = new Repository.Contact(Context, user).GetById(id);

            if (data == null)
            {
                return(null);
            }
            return(new Converter.Contact(Context).To(user.Id, data.Id));
        }