Ejemplo n.º 1
0
        public ActionResult Create(LeadCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            var service = new LeadService();

            service.CreateLead(model);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public ActionResult LeadCreate(LeadCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new LeadService(userId);

            service.CreateLead(model);

            return(RedirectToAction("LeadIndex"));
        }
Ejemplo n.º 3
0
        public IHttpActionResult Post(LeadCreate lead)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateLeadService();

            if (!service.CreateLead(lead))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Ejemplo n.º 4
0
        public bool CreateLead(LeadCreate model)
        {
            var entity =
                new Lead()
            {
                Name      = model.Name,
                Company   = model.Company,
                Phone     = model.Phone,
                Email     = model.Email,
                Converted = model.Converted
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Leads.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 5
0
        public ActionResult Create(LeadCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateLeadService();

            if (service.CreateLead(model))
            {
                TempData["SaveResult"] = "Your Lead was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Lead could not be created.");

            return(View(model));
        }
Ejemplo n.º 6
0
        public bool CreateLead(LeadCreate model)
        {
            var entity =
                new Lead()
            {
                OwnerID            = _userId,
                Company            = model.Company,
                Role               = model.Role,
                StatusID           = model.StatusID,
                SourceID           = model.SourceID,
                JobDescriptionLink = model.JobDescriptionLink,
                ResumeID           = model.ResumeID,
                CoverID            = model.CoverID,
                OtherArtifactID    = model.OtherArtifactUsedID,
                CreatedUtc         = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Leads.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }