/// <summary> /// Can only change properties: Name /// </summary> /// <param name="businessAccount">The business account</param> public void Put(BusinessAccount businessAccount) { var engine = EntityRules.SetupBusinessAccountRules(); var errors = EntityRules.ValidateAndReturnErrors(engine, businessAccount); if (errors != null) Request.BadRequest(errors); var modelBusinessAccount = CoreEntitiesContainer.BusinessAccount(businessAccount.Id, new[] { RoleType.Administrator }).FirstOrDefault(); if (modelBusinessAccount == null) throw Request.NotAuthorized(); modelBusinessAccount.Name = businessAccount.Name; modelBusinessAccount.LastModified = DateTime.UtcNow; modelBusinessAccount.LastModifyingUserId = CoreEntitiesContainer.CurrentUserAccount().Id; SaveWithRetry(); }
/// <summary> /// Returns the current business account with ImageUrl /// NOTE: Must have admin privileges /// </summary> public IQueryable<BusinessAccount> Get(Guid roleId) { var currentBusinessAccount = CoreEntitiesContainer.Owner(roleId, new[] { RoleType.Administrator }).FirstOrDefault(); if (currentBusinessAccount == null) throw Request.NotAuthorized(); currentBusinessAccount.PartyImageReference.Load(); var businessAccount = new BusinessAccount { Id = currentBusinessAccount.Id, CreatedDate = currentBusinessAccount.CreatedDate, Name = currentBusinessAccount.Name }; businessAccount.SetLastModified(currentBusinessAccount.LastModified, currentBusinessAccount.LastModifyingUserId); //Load image url if (currentBusinessAccount.PartyImage != null) { var imageUrl = currentBusinessAccount.PartyImage.RawUrl + AzureServerHelpers.GetBlobUrlHelper(currentBusinessAccount.Id, currentBusinessAccount.PartyImage.Id); businessAccount.ImageUrl = imageUrl; } return (new[] { businessAccount }).AsQueryable(); }