public IActionResult Add([FromBody] WbsDictionaryViewModel model) { try { var wbsDictionary = new WbsDictionary { ProjectNumber = model.ProjectNumber, CreatedBy = GetUserGuid(), WbsNumber = model.WbsNumber, WbsDictionaryTitle = model.WbsDictionaryTitle, CreatedOn = DateTime.Now }; _wbsDictionaryService.Add(wbsDictionary); return(Json(new { status = true })); } catch (Exception ex) { ModelState.Clear(); ModelState.AddModelError("", ex.Message); return(BadRequestFormatter.BadRequest(this, ex)); } }
public IActionResult Edit([FromBody] WbsDictionaryViewModel model) { try { var wbs = _wbsDictionaryService.GetWbsDictionaryByGuid(model.WbsDictionaryGuid); if (wbs == null) { throw new Exception("Unable to find WBS"); } wbs.WbsDictionaryTitle = model.WbsDictionaryTitle; wbs.CreatedOn = DateTime.Now; wbs.CreatedBy = GetUserGuid(); _wbsDictionaryService.Update(wbs); return(Json(new { status = true })); } catch (Exception ex) { ModelState.Clear(); ModelState.AddModelError("", ex.Message); return(BadRequestFormatter.BadRequest(this, ex)); } }