public bool UpdateAward(EditAwardVM award, HttpRequestBase request) { var updatedAward = Mapper.Map <AwardDTO>(award); if (request != null) { var uploaded = request.Files["Uploaded"]; if (uploaded != null && uploaded.ContentLength != 0) { byte[] bytes = new byte[uploaded.ContentLength]; uploaded.InputStream.Read(bytes, 0, uploaded.ContentLength); var img = new ImageDTO() { OwnerId = updatedAward.ImageId, Data = bytes, Type = uploaded.ContentType }; pictureBll.UpdateImage(img); } } return(awardBll.UpdateAward(updatedAward)); }
public bool UpdateUser(EditUserVM user, HttpRequestBase request) { var updatedUser = Mapper.Map <UserDTO>(user); var uploaded = request.Files["Uploaded"]; if (uploaded != null && uploaded.ContentLength != 0) { bool hadImage = true; byte[] bytes = new byte[uploaded.ContentLength]; uploaded.InputStream.Read(bytes, 0, uploaded.ContentLength); if (updatedUser.ImageId == Guid.Empty) { updatedUser.ImageId = Guid.NewGuid(); hadImage = false; } var img = new ImageDTO() { OwnerId = updatedUser.ImageId, Data = bytes, Type = uploaded.ContentType }; if (hadImage) { pictureBll.UpdateImage(img); } else { updatedUser.ImageId = pictureBll.AddImage(img); } } return(UpdateUser(updatedUser)); }