Ejemplo n.º 1
0
 public AddLeadPage()
 {
     NavigationPage.SetBackButtonTitle(this, "");
     InitializeComponent();
     BindingContext = _addLeadViewModel = new AddLeadViewModel(Navigation);
     _addLeadViewModel.Initialize();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Add new lead
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual async Task <ResultModel <Guid> > AddLeadAsync([Required] AddLeadViewModel model)
        {
            if (model == null)
            {
                return(new InvalidParametersResultModel <Guid>());
            }
            var lead = _mapper.Map <Lead>(model);

            var leadBd = await _context.Leads.FirstOrDefaultAsync(x =>
                                                                  x.PipeLineId == model.PipeLineId && x.Name.Trim().ToLower().Equals(model.Name.Trim().ToLower()));

            if (leadBd != null)
            {
                return new ResultModel <Guid>
                       {
                           IsSuccess = false,
                           Errors    = new List <IErrorModel> {
                               new ErrorModel {
                                   Message = "Lead [" + leadBd.Name + "] exist"
                               }
                           }
                       }
            }
            ;

            await _context.Leads.AddAsync(lead);

            var addLeadResult = await _context.PushAsync();

            return(addLeadResult.Map <Guid>(lead.Id));
        }
 public AddLead(ContactModel contactModel, string type)
 {
     NavigationPage.SetBackButtonTitle(this, "");
     InitializeComponent();
     BindingContext = _addLeadViewModel = new AddLeadViewModel(Navigation);
     _addLeadViewModel.Initialize(contactModel);
 }
Ejemplo n.º 4
0
 public async Task <JsonResult> AddLead([Required] AddLeadViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(JsonModelStateErrors());
     }
     return(await JsonAsync(_leadService.AddLeadAsync(model)));
 }