Beispiel #1
0
        public Models.Product Update(int id, Models.Product entity, string userName)
        {
            try
            {
                var old = RestfulProduct.Read(id);

                if (!ProductAccessControl.Pass(RestfulAction.Update, old, userName))
                {
                    throw new NoAccessException("No Access");
                }

                entity.VendorId = old.VendorId;
                entity.Title    = old.Title;
                entity.Version  = old.Version;
                entity.Creator  = userName;
                entity.Created  = old.Created;
                entity.Updated  = DateTime.Now;

                return(RestfulProduct.Update(id, entity));
            }
            catch
            {
                throw;
            }
        }
Beispiel #2
0
        public bool Delete(int id, string userName)
        {
            try
            {
                var entity = RestfulProduct.Read(id);

                if (!ProductAccessControl.Pass(RestfulAction.Delete, entity, userName))
                {
                    throw new NoAccessException("No Access");
                }

                return(RestfulProduct.Delete(id));
            }
            catch
            {
                throw;
            }
        }
Beispiel #3
0
        public Models.Product Read(int id, string userName = null)
        {
            try
            {
                var entity = RestfulProduct.Read(id);

                if (!ProductAccessControl.Pass(RestfulAction.Read, entity, userName))
                {
                    throw new NoAccessException("No Access");
                }

                return(entity);
            }
            catch
            {
                throw;
            }
        }
Beispiel #4
0
        public Models.Product First(Models.ProductSearchModel conditions = null, string userName = null)
        {
            try
            {
                var entity = RestfulProduct.First(conditions);

                if (!ProductAccessControl.Pass(RestfulAction.Read, entity, userName))
                {
                    throw new NoAccessException("No Access");
                }

                return(entity);
            }
            catch
            {
                throw;
            }
        }
Beispiel #5
0
        public Models.Product Create(Models.Product entity, string userName)
        {
            try
            {
                if (!ProductAccessControl.Pass(RestfulAction.Create, entity, userName))
                {
                    throw new NoAccessException("No Access");
                }

                entity.Creator = userName;
                entity.Created = DateTime.Now;

                return(RestfulProduct.Create(entity));
            }
            catch
            {
                throw;
            }
        }