示例#1
0
        public ActionResult Create(LeadCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            var service = new LeadService();

            service.CreateLead(model);

            return(RedirectToAction("Index"));
        }
示例#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"));
        }
示例#3
0
        public IHttpActionResult Post(LeadCreate lead)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateLeadService();

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

            return(Ok());
        }
示例#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);
            }
        }
示例#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));
        }
示例#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);
            }
        }