예제 #1
0
        public ServiceResult Update(Vendor v)
        {
            if (v == null)
            {
                return(ServiceResponse.Error("Invalid Vendor sent to server."));
            }


            if (CurrentUser == null)
            {
                return(ServiceResponse.Error("You must be logged in to access this function."));
            }

            VendorManager vendorManager = new VendorManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);

            var dbv = (Vendor)vendorManager.GetBy(v.UUID);

            if (dbv == null)
            {
                return(ServiceResponse.Error("Vendor was not found."));
            }

            if (dbv.DateCreated == DateTime.MinValue)
            {
                dbv.DateCreated = DateTime.UtcNow;
            }

            dbv.Deleted   = v.Deleted;
            dbv.Name      = v.Name;
            dbv.Status    = v.Status;
            dbv.SortOrder = v.SortOrder;


            return(vendorManager.Update(dbv));
        }
예제 #2
0
        public ServiceResult GetBy(string uuid)
        {
            if (CurrentUser == null)
            {
                return(ServiceResponse.Error("You must be logged in to access this function."));
            }

            VendorManager vendorManager = new VendorManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);

            Vendor s = (Vendor)vendorManager.GetBy(uuid);

            if (s == null)
            {
                return(ServiceResponse.Error("Vendor could not be located for the name " + uuid));
            }

            return(ServiceResponse.OK("", s));
        }
예제 #3
0
        public ServiceResult Delete(string vendorUUID)
        {
            if (string.IsNullOrWhiteSpace(vendorUUID))
            {
                return(ServiceResponse.Error("Invalid account was sent."));
            }

            if (CurrentUser == null)
            {
                return(ServiceResponse.Error("You must be logged in to access this function."));
            }

            VendorManager vendorManager = new VendorManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);

            Vendor v = (Vendor)vendorManager.GetBy(vendorUUID);

            return(this.Delete(v));
        }