public void Add(AddEditEducationInputModel input) { var dbModel = Mapper.Map <Education>(input); if (input.FileUploaded != null) { dbModel.ImageId = imageServices.Save(input.FileUploaded); } this.Data.Educations.Add(dbModel); this.Data.SaveChanges(); }
public void Save(AddEditEducationInputModel input) { var dbModel = Mapper.Map <Education>(input); if (input.FileUploaded != null) { // Delete the old image if (dbModel.ImageId != null) { imageServices.Delete(dbModel.ImageId.Value); } dbModel.ImageId = imageServices.Save(input.FileUploaded); } this.Data.Educations.Update(dbModel); this.Data.SaveChanges(); }