public void EditTypeMember(EditTypeMemberCommand command) { ThrowError.Against <ArgumentException>(string.IsNullOrEmpty(command.Name), String.Format(ErrorMessage.IsRequired, "Tên")); ThrowError.Against <ArgumentException>(_typeMemberService.Query(t => t.Name.ToUpper().Trim() == command.Name.ToUpper().Trim() && t.TypeMemberId != command.TypeMemberId).Select().Any(), String.Format(ErrorMessage.Exists, "Tên")); var count = _typeMemberService.Query(t => t.TypeMemberId != command.TypeMemberId && ((t.ScoresFrom < command.ScoresFrom && command.ScoresFrom < t.ScoresTo) || (t.ScoresFrom < command.ScoresTo && command.ScoresTo < t.ScoresTo) || (command.ScoresFrom < t.ScoresFrom && t.ScoresFrom < command.ScoresTo) || (command.ScoresFrom < t.ScoresTo && t.ScoresTo < command.ScoresTo) || (command.ScoresFrom == t.ScoresFrom && command.ScoresTo == t.ScoresTo))).Select().Count(); ThrowError.Against <ArgumentException>(count > 0, String.Format(ErrorMessage.IsNotTypemMember)); var typeMember = _typeMemberService.Find(command.TypeMemberId); typeMember.Name = command.Name; typeMember.PercentDownPayment = command.PercentDownPayment; typeMember.ScoresFrom = command.ScoresFrom; typeMember.ScoresTo = command.ScoresTo; _typeMemberService.Update(typeMember); _unitOfWork.SaveChanges(); }
public TypeMemberDTO GetById(Guid typeMemberId) { var typeMember = _typeMemberService.Find(typeMemberId); return(Mapper.Map <Domain.Entity.TypeMember, TypeMemberDTO>(typeMember)); }