public async Task <IActionResult> Update([FromRoute] Guid id, [FromBody] UpdateCompanyCommand command)
        {
            if (!command.Id.Equals(id))
            {
                return(BadRequest("Invalid Id passed from route"));
            }

            return(Ok(await appService.Update(command)));
        }
Esempio n. 2
0
        public async Task <IActionResult> Update([FromRoute] Guid id, [FromBody] UpdateCompanyCommand command)
        {
            var result = await appService.Get(id);

            if (result == null)
            {
                return(NotFound());
            }

            return(Ok(await appService.Update(command)));
        }
        public async Task Edit(CompanyDto companyDto)
        {
            if (companyDto.File != null)
            {
                companyDto.Logo = await SetLogo(companyDto.File);
            }


            await _companyAppService.Update(companyDto);

            return;
        }
 public ActionResult Edit([Bind(Include = "Id, Name")] CompanyViewModel company)
 {
     try
     {
         _companyAppService.Update(company);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(company));
     }
 }
        public async Task <CompanyViewModel> Update(UpdateCompanyCommand command)
        {
            //arrange
            const int expectedNumberOfErrors = 0;

            //act
            var response = await appService.Update(command);

            //assert
            command.ValidateModelAnnotations().Count.Should().Be(expectedNumberOfErrors);
            response.Id.Should().Be(command.Id);
            response.Name.Should().Be(command.Name);

            return(response);
        }
Esempio n. 6
0
        public ActionResult Edit(int id, CompanyViewModel companyViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var company = Mapper.Map <CompanyViewModel, Company>(companyViewModel);
                    _companyApp.Update(company);

                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View(companyViewModel));
            }
            return(View(companyViewModel));
        }
Esempio n. 7
0
        public IHttpActionResult UpdateCompany(CompanyModel companyModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var companyDto = Mapper.Map <CompanyDto>(companyModel);

                _companyAppService.Update(companyDto, AuthHelper.GetCurrentUserId());

                return(Ok("Company Updated"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task <IHttpActionResult> UpdateAsync([FromBody] CompanySummary company)
        {
            //var companyEntity = TypeAdapter.Adapt<CompanySummary, CompanyEntity>(company);

            var results = new CompanySummaryValidator().Validate(company);

            if (!results.IsValid)
            {
                return(this.BadRequest(string.Join(" , ", results.Errors)));
            }

            var companyEntity = company.ToEntity();

            var updatedCompany = await Task.Run(() => _companyAppService.Update(companyEntity));


            var viewModel = TypeAdapter.Adapt <CompanyEntity, CompanySummary>(updatedCompany);

            return(this.Ok(viewModel));
        }