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)); }
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)); }
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)); }