public async Task <IHttpActionResult> Post([FromBody] MenuViewModel model) { try { model.IsActive = true; var creationResult = await _menu.CreateAsync(model); if (creationResult != null) { model.Id = creationResult.Id; } var result = new { Error = creationResult == null, Message = creationResult == null ? "Menu Creation failed." : "", Data = creationResult == null ? null : model }; return(Ok(result)); } catch (Exception ex) { ex.WriteLog(); return(BadRequest("Menu Creation failed.")); } }
public async Task <ActionResult> Create(MenuViewModel model, int page = 1) { if (!ModelState.IsValid) { model.ParentList = await _menu.LoadParentAsync(); model.RoleList = await _role.LoadParentAsync(); return(PartialView("Save", model)); } var result = await _menu.CreateAsync(model); return (Json( new { redirectTo = Url.Action("Index", "Menu", new { Area = "Admin", page }), message = result == null ? "Record creation Failed!!!" : "Record created successfully!!!", position = "mainContent" })); }