public void UpdateBackground(BackgroundDto backgroundDto, string path) { var background = _backgroundService.Find(backgroundDto.BackgroundId); if (background == null) { throw new NotFoundException(ErrorCodes.BackgroundNotFound); } _backgroundService.Update(background); SaveChanges(); if (backgroundDto.IsImageChange) { _manageStorage.UploadImage(path + "\\" + "Background", backgroundDto.Image, background.BackgroundId.ToString()); } }
public void AddBackground(BackgroundDto backgroundDto, string path) { var background = Mapper.Map <Background>(backgroundDto); background.CreationTime = DateTime.Now; background.LastModificationTime = DateTime.Now; background.DeletionTime = DateTime.Now; background.IsActive = true; _backgroundService.Insert(background); SaveChanges(); var changeResturentBackground = _restaurantService.GetRestaurantByAdminId(backgroundDto.UserId); changeResturentBackground.BackgroundId = background.BackgroundId; _restaurantService.Update(changeResturentBackground); SaveChanges(); _manageStorage.UploadImage(path + "\\" + "Background", backgroundDto.Image, background.BackgroundId.ToString()); }