예제 #1
0
        public async Task <IActionResult> Edit(EditInvestigationViewModel model)
        {
            if (ModelState.IsValid)
            {
                var investigation = await _investigationManager.FindByIdAsync(model.Id);

                if (investigation == null)
                {
                    return(NotFound(model.Id));
                }
                try
                {
                    investigation        = Mapper.Map(model, investigation);
                    investigation.Status = InvestigationStatus.Ongoing;
                    if (investigation.IsConnected.HasValue && investigation.IsConnected.Value)
                    {
                        investigation.UnconnectedRemark = string.Empty;
                    }
                    await _investigationManager.UpdateAsync(investigation);

                    Notifier.Success($"你已成功编辑了“{investigation.Name}”的意向调查记录!");
                }
                catch (Exception ex)
                {
                    Notifier.Warning(ex.Message);
                }
                return(RedirectToAction(nameof(List)));
            }
            return(View(model));
        }