public string Insert(StaffsDto dto) { var conn = _baseInterface.GetConnection(); var transaction = conn.BeginTransaction(); string message = ""; try { var photoStorage = new PhotoStorages(); photoStorage.Photo = null; photoStorage.PhotoLocation = null; int photoStorageId = _photoStorageRepository.Insert(photoStorage, transaction, conn); var user = dto.ToUserEntity(); user.PhotoStorageId = photoStorageId; user.Password = Web.Repositories.Utitlities.Security.GetMd5Sum(dto.Password); user.CreatedDate = DateTime.Now; user.CreatedBy = Convert.ToInt32(HttpContext.Current.Session["UserId"]); int userId = _usersRepository.Insert(user, transaction, conn); var staff = dto.ToEntity(); staff.UserId = userId; int staffId = _staffsRepository.Insert(staff, transaction, conn); message = _messageClass.ShowSuccessMessage(staffId); transaction.Commit(); } catch (SqlException ex) { message = _messageClass.ShowErrorMessage(string.Format("{0} ~ {1}", ex.Number.ToString(), ex.Message)); transaction.Rollback(); } return(message); }
public int Update(PhotoStorages entity, IDbTransaction transaction, SqlConnection con) { return(_photoStorageRepoRepo.Update(entity, transaction, con)); }
public int Insert(PhotoStorages entity, IDbTransaction transaction, SqlConnection con) { return(_photoStorageRepoRepo.Insert(entity, transaction, con)); }