public async Task <IHttpActionResult> Post([FromBody] BranchViewModel model)
        {
            model.ParentId = 1;
            model.Active   = true;
            try
            {
                var branch = await _branch.CreateAsync(model);

                if (branch != null)
                {
                    model.Id = branch.Id;
                }

                var result = new
                {
                    Error   = branch == null,
                    Message = branch == null ? "Branch Creation failed." : "",
                    Data    = branch == null ? null : model
                };
                return(Ok(result));
            }
            catch (Exception ex)
            {
                ex.WriteLog();
                return(BadRequest("Branch Creation failed."));
            }
        }
示例#2
0
        public async Task <ActionResult> Create(BranchViewModel model, int page = 1)
        {
            if (!ModelState.IsValid)
            {
                //model.ParentList = _branch.LoadParents();
                return(PartialView("Save", model));
            }

            var result = await _branch.CreateAsync(model);

            return
                (Json(
                     new
            {
                redirectTo = Url.Action("Index", "Branch", new { Area = "Admin", page }),
                message = result == null ? "Record creation Failed!!!" : "Record created successfully!!!",
                position = "mainContent"
            }));
        }