Пример #1
0
        public JsonResult Negotiation_Insert(AddNegotiationRequest request)
        {
            GeneralResponse response = new GeneralResponse();

            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("Negotiation_Insert");
            if (!hasPermission)
            {
                response.ErrorMessages.Add("AccessDenied");
                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            #endregion

            response = _negotiationService.AddNegotiation(request, GetEmployee().ID);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public GeneralResponse AddNegotiation(AddNegotiationRequest request, Guid EmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                Negotiation negotiation = new Negotiation();

                negotiation.ID                = Guid.NewGuid();
                negotiation.CreateDate        = PersianDateTime.Now;
                negotiation.CreateEmployee    = _employeeRepository.FindBy(EmployeeID);
                negotiation.RowVersion        = 1;
                negotiation.Customer          = _customerRepository.FindBy(request.CustomerID);
                negotiation.LeadTitleTemplate = _leadTitleTemplateRepository.FindBy(request.LeadTitleTemplateID);
                negotiation.NegotiationDate   = request.NegotiationDate;
                negotiation.NegotiationTime   = request.NegotiationTime;
                negotiation.RememberTime      = request.RememberTime;
                negotiation.SendSms           = request.SendSms != null && (bool)request.SendSms;
                negotiation.ReferedEmployee   = request.ReferedEmployeeID == null
                    ? _employeeRepository.FindBy(EmployeeID)
                    : _employeeRepository.FindBy((Guid)request.ReferedEmployeeID);

                negotiation.NegotiationDesciption = request.NegotiationDesciption;


                _negotiationRepository.Add(negotiation);
                _uow.Commit();
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }