public RequestModel(Request request, bool withComments = false) { Id = request.Id; Type = (RequestType)request.Type; State = (RequestState) request.State; Amount = request.Amount; Date = request.Date; AssignedOperatorId = request.AssignedOperatorId; AssignedSecurityWorkerId = request.AssignedSecurityWorkerId; ClientId = request.ClientId; MonthIncome = request.MonthIncome; if (Type == RequestType.Credit && request.CreditTypeId.HasValue) { CreditTypeId = request.CreditTypeId.Value; if (request.CreditType != null) { TypeName = String.Format("{0} {1}", request.CreditType.Name, request.CreditType.CurrencyShort); } } else if (Type == RequestType.Deposit && request.DepositTypeId.HasValue) { DepositTypeId = request.DepositTypeId.Value; if (request.DepositType != null) { TypeName = String.Format("{0} {1}", request.DepositType.Name, request.DepositType.CurrencyShort); } } if (withComments) { Comments = request.Comment.Select(item => new CommentModel(item)).OrderBy(item => item.Date).ToList(); } }
public void CreateRequest(RequestModel requestModel) { var date = dateService.GetCurrentDate(); var request = new Request { ClientId = requestModel.ClientId, Type = (int) requestModel.Type, State = (int) requestModel.State, Amount = requestModel.Amount, MonthIncome = requestModel.MonthIncome, CreditTypeId = requestModel.CreditTypeId, DepositTypeId = requestModel.DepositTypeId, Date = date }; requestRepository.CreateRequest(request); }