Example #1
0
        private async void OnSave()
        {
            var editingCompany = Mapper.Map <EditableCompany, Company>(Company);

            editingCompany.RelatedPeople = RelatedPersonListViewModel.RelatedPeople;

            try
            {
                if (EditMode)
                {
                    await _companiesService.UpdateCompanyAsync(editingCompany);
                }
                else
                {
                    await _companiesService.AddCompanyAsync(editingCompany);
                }
                Done?.Invoke();
            }
            catch (Exception ex)
            {
                Failed(ex);
            }
            finally
            {
                Company = null;
            }
        }
Example #2
0
        public async Task <IActionResult> Add(AddCompanyViewModel company)
        {
            //TODO: make company add friendly error page
            if (!ModelState.IsValid)
            {
                this.TempData.AddFailureMessage(string.Format(FailureAddItemMessage, company.Name));
                return(this.RedirectToAction(nameof(Index)));
                //return this.BadRequest();
            }

            await companiesServices.AddCompanyAsync(company.Name);

            this.TempData.AddSuccessMessage(string.Format(SuccessAddItemMessage, company.Name));
            return(this.RedirectToAction(nameof(Index)));
        }