Example #1
0
        public async Task <IActionResult> UpdateMaster(FieldMasterViewModel model)
        {
            if (model == null)
            {
                ViewBag.ErrorMessage = $"Role with Id ={model.Id} cannot be found";
                return(View("../Error/NotFound"));
            }
            else
            {
                JsonPatchDocument <FieldMaster> patchDoc = new JsonPatchDocument <FieldMaster>();
                patchDoc.Replace(e => e.Status, model.Status);
                patchDoc.Replace(e => e.Description, model.Description);
                var response = await ApiClientFactory.Instance.UpdateFieldMaster(model.Id, patchDoc);

                return(RedirectToAction("FieldMaster"));
            }
        }
Example #2
0
        public async Task <IActionResult> CreateMaster([Bind(include: "GroupCode,Name,Status,Description")] FieldMasterViewModel model)
        {
            if (ModelState.IsValid)
            {
                FieldMaster fmaster = new FieldMaster()
                {
                    GroupCode   = model.GroupCode.ToUpper(),
                    Name        = model.Name,
                    Status      = model.Status,
                    CreateDate  = CommonMethod.GetCurrentDate(),
                    Description = model.Description
                };
                var response = await ApiClientFactory.Instance.SaveCommonMasterDetails(fmaster);

                if (response.StatusCode == 201)
                {
                    return(RedirectToAction("FieldMaster"));
                }
            }

            return(View("../Internal/CommonMaster", model));
        }