Пример #1
0
        public ActionResult LeadEdit(int id, LeadEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.LeadID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

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

            if (service.UpdateLead(model))
            {
                TempData["SaveResult"] = "Your Lead was updated.";
                return(RedirectToAction("LeadIndex"));
            }

            ModelState.AddModelError("", "Your Lead could not be updated.");
            return(View(model));
        }
Пример #2
0
        public ActionResult Edit(int id)
        {
            var service = CreateLeadService();
            var detail  = service.GetLeadById(id);
            var model   =
                new LeadEdit
            {
                LeadId  = detail.LeadId,
                Content = detail.Content,
                Status  = detail.Status,
            };

            return(View(model));
        }
Пример #3
0
        public IHttpActionResult Put(LeadEdit lead)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateLeadService();

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

            return(Ok());
        }
Пример #4
0
        public bool UpdateLead(LeadEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Leads
                    .Single(e => e.LeadId == model.LeadId);

                entity.Content = model.Content;
                entity.Status  = (string)model.Status;


                return(ctx.SaveChanges() == 1);
            }
        }
Пример #5
0
        public bool UpdateLead(LeadEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Leads
                    .Single(e => e.ID == model.ID);    // && e.OwnerId == _userId);
                entity.Name      = model.Name;
                entity.Company   = model.Company;
                entity.Phone     = model.Phone;
                entity.Email     = model.Email;
                entity.Converted = model.Converted;

                return(ctx.SaveChanges() == 1);
            }
        }
Пример #6
0
        public ActionResult Edit(int id)

        {
            var service = new LeadService();
            var detail  = service.GetLeadByID(id);
            var model   =
                new LeadEdit
            {
                ID        = detail.ID,
                Name      = detail.Name,
                Company   = detail.Company,
                Phone     = detail.Phone,
                Email     = detail.Email,
                Converted = detail.Converted
            };

            return(View(model));
        }
Пример #7
0
        public bool UpdateLead(LeadEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Leads
                    .Single(e => e.LeadID == model.LeadID && e.OwnerID == _userId);

                entity.Company            = model.Company;
                entity.Role               = model.Role;
                entity.SourceID           = model.SourceID;
                entity.StatusID           = model.StatusID;
                entity.JobDescriptionLink = model.JobDescriptionLink;
                entity.ResumeID           = model.ResumeID;
                entity.CoverID            = model.CoverID;
                entity.OtherArtifactID    = model.OtherArtifactID;
                entity.ModifiedUtc        = DateTimeOffset.UtcNow;
                return(ctx.SaveChanges() == 1);
            }
        }
Пример #8
0
        public ActionResult LeadEdit(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new LeadService(userId);
            var detail  = service.GetLeadById(id);
            var model   =
                new LeadEdit
            {
                LeadID             = detail.LeadID,
                Role               = detail.Role,
                Company            = detail.Company,
                StatusID           = detail.StatusID,
                SourceID           = detail.SourceID,
                JobDescriptionLink = detail.JobDescriptionLink,
                ResumeID           = detail.ResumeID,
                CoverID            = detail.CoverID,
                OtherArtifactID    = detail.OtherArtifactID,
                CreatedUtc         = DateTimeOffset.Now
            };

            return(View(model));
        }
Пример #9
0
        public ActionResult Edit(int id, LeadEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.ID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = new LeadService();

            if (service.UpdateLead(model))
            {
                TempData["SaveResult"] = "Lead Details Successfully Updated";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Failed to Update Lead");
            return(View(model));
        }
Пример #10
0
        public ActionResult Edit(int id, LeadEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.LeadId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateLeadService();

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

            ModelState.AddModelError("", "Your Lead could not be updated.");
            return(View(model));
        }