Esempio n. 1
0
        public async Task <ActionResult> EditCompany(long id, [FromBody] EditCompanyViewModel model)
        {
            var command = new EditCompanyCommand(id, model.Name, model.EstablishmentYear, model.Employees);
            var result  = await this.mediator.Send(command);

            return(NoContent());
        }
        public void Execute_Returns_Created_Company()
        {
            // Setup
            InitializeTestEntities();

            // Act
            Company result = new EditCompanyCommand(_serviceFactory.Object).WithCompanyId(_company.Id)
                             .SetName("Name")
                             .SetPhone("555-555-5555")
                             .SetCity("City")
                             .SetState("State")
                             .SetZip("01234")
                             .SetMetroArea("Metro")
                             .SetIndustry("Industry")
                             .SetNotes("Notes")
                             .RequestedByUserId(_user.Id)
                             .Execute();

            // Verify
            Assert.IsNotNull(result, "Returned company entity was null");
            Assert.AreEqual("Name", result.Name, "The created company's name was incorrect");
            Assert.AreEqual("555-555-5555", result.Phone, "The created company's phone number was incorrect");
            Assert.AreEqual("City", result.City, "The created company's city was incorrect");
            Assert.AreEqual("State", result.State, "The created company's state was incorrect");
            Assert.AreEqual("01234", result.Zip, "The created company's zip was incorrect");
            Assert.AreEqual("Metro", result.MetroArea, "The created company's metro area was incorrect");
            Assert.AreEqual("Notes", result.Notes, "The created company's notes were incorrect");
            Assert.AreEqual("Industry", result.Industry, "The created company's industry was incorrect");
        }
Esempio n. 3
0
        public async Task <Result> Edit([FromBody] EditCompanyCommand cmd)
        {
            _logger.LogInformation($"接收到请求{HttpContext.Request.Host}{HttpContext.Request.Path},参数 {JsonConvert.SerializeObject(cmd)}");

            cmd.LoginUser = this.GetCurrentUser();

            var result = await _mediator.Send(cmd, HttpContext.RequestAborted);

            return(result);
        }
Esempio n. 4
0
 public JigsawCompanySearchProcesses(MyJobLeadsDbContext context,
                                     CompanyByIdQuery companyQuery,
                                     CreateCompanyCommand createCompanyCmd,
                                     EditCompanyCommand editCompanyCmd)
 {
     _context          = context;
     _companyByIdQuery = companyQuery;
     _createCompanyCmd = createCompanyCmd;
     _editCompanyCmd   = editCompanyCmd;
 }
Esempio n. 5
0
        public virtual ActionResult Edit(EditCompanyViewModel model)
        {
            Company company;

            try
            {
                // Determine if this is a new company or not
                if (model.Id == 0)
                {
                    company = new CreateCompanyCommand(_serviceFactory).WithJobSearch(model.JobSearchId)
                              .SetName(model.Name)
                              .SetCity(model.City)
                              .SetIndustry(model.Industry)
                              .SetMetroArea(model.MetroArea)
                              .SetNotes(model.Notes)
                              .SetPhone(model.Phone)
                              .SetState(model.State)
                              .SetZip(model.Zip)
                              .SetWebsite(model.Website)
                              .CalledByUserId(CurrentUserId)
                              .Execute();
                }
                else
                {
                    company = new EditCompanyCommand(_serviceFactory).WithCompanyId(model.Id)
                              .SetName(model.Name)
                              .SetCity(model.City)
                              .SetIndustry(model.Industry)
                              .SetMetroArea(model.MetroArea)
                              .SetNotes(model.Notes)
                              .SetPhone(model.Phone)
                              .SetState(model.State)
                              .SetZip(model.Zip)
                              .SetLeadStatus(model.LeadStatus)
                              .SetWebsite(model.Website)
                              .RequestedByUserId(CurrentUserId)
                              .Execute();
                }

                return(RedirectToAction(MVC.Company.Details(company.Id)));
            }

            catch (ValidationException ex)
            {
                foreach (var error in ex.Errors)
                {
                    ModelState.AddModelError(error.PropertyName, error.ErrorMessage);
                }

                model.AvailableLeadStatuses = _serviceFactory.GetService <LeadStatusesAvailableForCompaniesQuery>().Execute();
                return(View(model));
            }
        }
Esempio n. 6
0
        public virtual ActionResult Edit(EditCompanyViewModel model)
        {
            Company company;

            try
            {
                // Determine if this is a new company or not
                if (model.Id == 0)
                {
                    company = new CreateCompanyCommand(_serviceFactory).WithJobSearch(model.JobSearchId)
                                                                          .SetName(model.Name)
                                                                          .SetCity(model.City)
                                                                          .SetIndustry(model.Industry)
                                                                          .SetMetroArea(model.MetroArea)
                                                                          .SetNotes(model.Notes)
                                                                          .SetPhone(model.Phone)
                                                                          .SetState(model.State)
                                                                          .SetZip(model.Zip)
                                                                          .SetWebsite(model.Website)
                                                                          .CalledByUserId(CurrentUserId)
                                                                          .Execute();
                }
                else
                {
                    company = new EditCompanyCommand(_serviceFactory).WithCompanyId(model.Id)
                                                                          .SetName(model.Name)
                                                                          .SetCity(model.City)
                                                                          .SetIndustry(model.Industry)
                                                                          .SetMetroArea(model.MetroArea)
                                                                          .SetNotes(model.Notes)
                                                                          .SetPhone(model.Phone)
                                                                          .SetState(model.State)
                                                                          .SetZip(model.Zip)
                                                                          .SetLeadStatus(model.LeadStatus)
                                                                          .SetWebsite(model.Website)
                                                                          .RequestedByUserId(CurrentUserId)
                                                                          .Execute();
                }

                return RedirectToAction(MVC.Company.Details(company.Id));
            }

            catch (ValidationException ex)
            {
                foreach (var error in ex.Errors)
                    ModelState.AddModelError(error.PropertyName, error.ErrorMessage);

                model.AvailableLeadStatuses = _serviceFactory.GetService<LeadStatusesAvailableForCompaniesQuery>().Execute();
                return View(model);
            }
        }