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();
   }
Exemplo n.º 2
0
 private void Save(TypeMemberModel model)
 {
   if (model.TypeMemberId == Guid.Empty)
   {
     var createCommand = new AddTypeMemberCommand(model.Name,model.ScoresFrom,model.ScoresTo,model.PercentDownPayment);
     model.TypeMemberId = _typeMemberCommandService.AddTypeMember(createCommand);
   }
   else
   {
     var updateCommand = new EditTypeMemberCommand(model.TypeMemberId, model.Name, model.ScoresFrom, model.ScoresTo, model.PercentDownPayment);
     _typeMemberCommandService.EditTypeMember(updateCommand);
   }
 }