Пример #1
0
        public ActionResult EditRespGroupDetail(CreateEditRespGroupDetailViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(model);
                var    endpoint = String.Format("{0}/ValidateIsAxists", url);
                var    isAxists = Utilities.RestAPIHelper <AjaxViewModel> .Submit(json, Method.POST, endpoint, Request);

                if (!isAxists.IsSuccess)
                {
                    jsonViewModel.SetValues(isAxists.IsSuccess, null, isAxists.Message);
                }
                else
                {
                    endpoint = url + "/EditRespGroupDetail";

                    model = Utilities.RestAPIHelper <CreateEditRespGroupDetailViewModel>
                            .Submit(json, Method.PUT, endpoint, Request);

                    jsonViewModel.SetValues(true, null, "Saved");
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
Пример #2
0
        public ActionResult CreateCity(CreateEditCityViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(model);
                var    endpoint = url + "/ValidateCity";
                var    isValid  = Utilities.RestAPIHelper <AjaxViewModel> .Submit(json, Method.POST, endpoint);

                if (!isValid.IsSuccess)
                {
                    jsonViewModel.SetValues(isValid.IsSuccess, null, isValid.Message);
                }
                else
                {
                    var decryptID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.ProvinceID));
                    endpoint = url + "/AddCity/" + decryptID;
                    var content = Utilities.RestAPIHelper <CreateEditCityViewModel>
                                  .Submit(json, Method.POST, endpoint, Request);

                    jsonViewModel.SetValues(true, null, "Saved");
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
Пример #3
0
        public ActionResult Create(CreateEditViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                var cekCode = Utilities.RestAPIHelper <string>
                              .Submit("", Method.GET, url + "/ValidateLevelCategoryCode/" + model.Code);

                if (Convert.ToBoolean(cekCode))
                {
                    jsonViewModel.SetValues(false, null, String.Format("Code sudah terdaftar"));
                }
                else
                {
                    string json     = JsonConvert.SerializeObject(model);
                    var    endpoint = url + Route.Add;
                    var    content  = Utilities.RestAPIHelper <CreateEditViewModel>
                                      .Submit(json, Method.POST, endpoint, Request);

                    jsonViewModel.SetValues(true, null, "Saved");
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }

            return(Json(jsonViewModel));
        }
Пример #4
0
        public ActionResult Edit(CreateEditViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                var checkCode = Utilities.RestAPIHelper <string>
                                .Submit("", Method.GET, url + "/IsCodeValid/" + model.Code + "/" + model.ID, Request);

                if (Convert.ToBoolean(checkCode) == true)
                {
                    jsonViewModel.SetValues(false, null, String.Format("Code has been used"));
                }
                else
                {
                    var decryptedID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.ID));
                    model.ID = decryptedID.ToString();

                    string json     = JsonConvert.SerializeObject(model);
                    var    endpoint = url + Route.Edit;
                    model = Utilities.RestAPIHelper <CreateEditViewModel>
                            .Submit(json, Method.PUT, endpoint, Request);

                    jsonViewModel.SetValues(true, null, "Saved");
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
Пример #5
0
        public ActionResult DeleteGradeDetail(string[] arrayOfID)
        {
            var ajaxViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(arrayOfID);
                var    endpoint = String.Format("{0}/DeleteGradeDetail/{1}", url, json);

                var result = Utilities.RestAPIHelper <string>
                             .Submit("", Method.POST, endpoint, Request);

                if (Convert.ToBoolean(result))
                {
                    ajaxViewModel.SetValues(false, null, "Grade already used by Employee");
                }
                else
                {
                    ajaxViewModel.SetValues(true, null, "Deleted Successfully");
                }
            }
            catch (Exception ex)
            {
                ajaxViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }

            return(Json(ajaxViewModel));
        }
        public ActionResult CreateClassification(CreateEditClassificationViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                string json      = JsonConvert.SerializeObject(model);
                var    endpoint  = url + "/ValidateCodeExistClassification";
                var    checkCode = Utilities.RestAPIHelper <string>
                                   .Submit(json, Method.POST, endpoint, Request);

                if (Convert.ToBoolean(checkCode) == true)
                {
                    jsonViewModel.SetValues(false, null, String.Format("Code has been used"));
                }
                else
                {
                    endpoint = url + "/AddClassification";
                    var content = Utilities.RestAPIHelper <CreateEditViewModel>
                                  .Submit(json, Method.POST, endpoint, Request);

                    jsonViewModel.SetValues(true, null, "Saved");
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
Пример #7
0
        public ActionResult Delete(string[] arrayOfID)
        {
            var ajaxViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(arrayOfID);
                var    endpoint = url + Route.Delete + "/" + json;
                var    result   = Utilities.RestAPIHelper <string>
                                  .Submit("", Method.POST, endpoint, Request);

                if (Convert.ToBoolean(result))
                {
                    ajaxViewModel.SetValues(false, null, "Organization Level already used by Organization Unit");
                }
                else
                {
                    ajaxViewModel.SetValues(true, null, "Deleted Successfully");
                }
            }
            catch (Exception ex)
            {
                ajaxViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }

            return(Json(ajaxViewModel));
        }
Пример #8
0
        public ActionResult Create(CreateEditViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(model);
                var    endpoint = String.Format("{0}{1}", url, Route.Validate);
                var    isValid  = Utilities.RestAPIHelper <AjaxViewModel> .Submit(json, Method.POST, endpoint);

                if (!isValid.IsSuccess)
                {
                    jsonViewModel.SetValues(isValid.IsSuccess, null, isValid.Message);
                }
                else
                {
                    endpoint = String.Format("{0}{1}", url, Route.Add);
                    var content = Utilities.RestAPIHelper <CreateEditViewModel> .Submit(json, Method.POST, endpoint, Request);

                    jsonViewModel.SetValues(true, null, "Saved");
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
Пример #9
0
        public ActionResult Edit(CreateEditViewModel model)
        {
            //var decryptedID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.ID));
            //model.ID = decryptedID.ToString();
            var jsonViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(model);
                var    endpoint = String.Format("{0}{1}", url, Route.Validate);
                var    isValid  = Utilities.RestAPIHelper <AjaxViewModel> .Submit(json, Method.POST, endpoint, Request);

                if (!isValid.IsSuccess)
                {
                    jsonViewModel.SetValues(isValid.IsSuccess, null, isValid.Message);
                }
                else
                {
                    endpoint = url + Route.Edit;
                    Utilities.RestAPIHelper <CreateEditViewModel> .Submit(json, Method.PUT, endpoint, Request);

                    jsonViewModel.SetValues(true, null, "Saved");
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
Пример #10
0
        public ActionResult EditSpecification(CreateEditSpecificationViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                model.ID         = EncryptionHelper.DecryptUrlParam(model.ID);
                model.JobTitleID = EncryptionHelper.DecryptUrlParam(model.JobTitleID);
                string json     = JsonConvert.SerializeObject(model);
                var    endpoint = String.Format("{0}/{1}", url, "SpecificationValidateCombination");
                var    check    = Utilities.RestAPIHelper <string>
                                  .Submit(json, Method.POST, endpoint, Request);

                if (!Convert.ToBoolean(check))
                {
                    endpoint = String.Format("{0}/{1}", url, "EditSpecification");
                    var content = Utilities.RestAPIHelper <CreateEditSpecificationViewModel>
                                  .Submit(json, Method.POST, endpoint, Request);

                    return(RedirectToAction("Index"));
                }
                else
                {
                    jsonViewModel.SetValues(false, null, String.Format("Specification has been exist"));
                    return(Json(jsonViewModel));
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
                return(Json(jsonViewModel));
            }
        }
Пример #11
0
        public ActionResult Edit(CreateEditViewModel model)
        {
            var  jsonViewModel = new AjaxViewModel();
            bool IsValidEmail;

            try
            {
                var addr = new System.Net.Mail.MailAddress(model.Email);
                model.Email  = addr.ToString();
                IsValidEmail = true;
            }
            catch
            {
                IsValidEmail = false;
            }

            if (!IsValidEmail)
            {
                jsonViewModel.SetValues(false, null, String.Format("Email is invalid"));
            }
            else
            {
                try
                {
                    var decryptedID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.ID));
                    model.ID         = decryptedID.ToString();
                    model.EmployeeID = EncryptionHelper.DecryptUrlParam(model.EmployeeID);
                    string json      = JsonConvert.SerializeObject(model);
                    var    checkCode = Utilities.RestAPIHelper <string>
                                       .Submit(json, Method.POST, url + "/UserValidateCombination");

                    if (!Convert.ToBoolean(checkCode))
                    {
                        var endpoint = url + Route.Edit;
                        model = Utilities.RestAPIHelper <CreateEditViewModel>
                                .Submit(json, Method.PUT, endpoint);

                        jsonViewModel.SetValues(true, null, "Saved");
                    }
                    else
                    {
                        jsonViewModel.SetValues(false, null, String.Format("User has been added"));
                    }
                }
                catch (Exception ex)
                {
                    jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
                }
            }

            return(Json(jsonViewModel));
        }
Пример #12
0
        public JsonResult List([DataSourceRequest] DataSourceRequest request)
        {
            // Must Convert to Json from kendo data source request , because filter using abstract class
            AjaxViewModel    jsonViewModel       = new AjaxViewModel();
            DataSourceResult newDataSourceResult = new DataSourceResult();

            try
            {
                //DataClaim.GetClaim(Request);
                var json = Utilities.GridUtilities.ConvertKendoRequestToJson(request);

                var urlEndPoint = url + Route.Get;

                var query = Utilities.RestAPIHelper <CustomDataSourceResult <ListResponsibiltyViewModel> >
                            .Submit(json, Method.POST, urlEndPoint, Request);

                newDataSourceResult.Data  = query.data;
                newDataSourceResult.Total = query.total;

                foreach (var item in query.data)
                {
                    item.ID          = EncryptionHelper.EncryptUrlParam(item.ID);
                    item.Description = item.Description == null ? item.Description = "N/A" : item.Description;
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }

            return(Json(newDataSourceResult));
        }
Пример #13
0
        public ActionResult EditGradeDetail(string id)
        {
            var jsonViewModel = new AjaxViewModel();
            CreateEditGradeDetailViewModel model = new CreateEditGradeDetailViewModel();

            try
            {
                int decryptID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(id));
                var endpoint  = String.Format("{0}/GetGradeDetail/{1}", url, decryptID);

                model = Utilities.RestAPIHelper <CreateEditGradeDetailViewModel>
                        .Submit("", Method.GET, endpoint, Request);

                string encryptID = EncryptionHelper.EncryptUrlParam(model.GroupGradeID);

                var maxSequence = String.Format("{0}/MaxSequenceLevel/{1}", url, encryptID);

                model.MaxSequence = Utilities.RestAPIHelper <int>
                                    .Submit("", Method.GET, maxSequence, Request);
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(PartialView("CreateEditGradeDetail", model));
        }
Пример #14
0
        public JsonResult ListGradeDetail([DataSourceRequest] DataSourceRequest request, string headerID = null)
        {
            // Must Convert to Json from kendo data source request , because filter using abstract class
            headerID = headerID ?? EncryptionHelper.EncryptUrlParam(TempData.Peek("ID").ToString());
            var              decryptedId         = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(headerID));
            AjaxViewModel    jsonViewModel       = new AjaxViewModel();
            DataSourceResult newDataSourceResult = new DataSourceResult();

            try
            {
                var json = Utilities.GridUtilities.ConvertKendoRequestToJson(request);

                var endpoint = String.Format("{0}/GetListGradeDetail/{1}", url, decryptedId);

                var result = Utilities.RestAPIHelper <CustomDataSourceResult <ListGradeDetailViewModel> >
                             .Submit(json, Method.POST, endpoint, Request);

                newDataSourceResult.Data  = result.data;
                newDataSourceResult.Total = result.total;

                foreach (var item in result.data)
                {
                    item.ID = EncryptionHelper.EncryptUrlParam(item.ID);
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(newDataSourceResult));
        }
        public JsonResult List([DataSourceRequest] DataSourceRequest request)
        {
            AjaxViewModel    jsonViewModel       = new AjaxViewModel();
            DataSourceResult newDataSourceResult = new DataSourceResult();

            try
            {
                var json     = Utilities.GridUtilities.ConvertKendoRequestToJson(request);
                var endpoint = url + Route.Get;

                var result = Utilities.RestAPIHelper <CustomDataSourceResult <ListLocationClassificationViewModel> >
                             .Submit(json, Method.POST, endpoint);

                newDataSourceResult.Data  = result.data;
                newDataSourceResult.Total = result.total;

                foreach (var item in result.data)
                {
                    item.ID          = EncryptionHelper.EncryptUrlParam(item.ID);
                    item.Description = item.Description == null ? item.Description = "N/A" : item.Description;
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(newDataSourceResult));
        }
Пример #16
0
        public IActionResult ListRespGroupDetail([DataSourceRequest] DataSourceRequest request, string HeaderID)
        {
            // Must Convert to Json from kendo data source request , because filter using abstract class
            AjaxViewModel    jsonViewModel       = new AjaxViewModel();
            DataSourceResult newDataSourceResult = new DataSourceResult();

            try
            {
                var json        = Utilities.GridUtilities.ConvertKendoRequestToJson(request);
                int ID          = Convert.ToInt32(HeaderID);
                var urlEndPoint = url + "/GetListRespGroupDetail/" + ID;

                var query = Utilities.RestAPIHelper <CustomDataSourceResult <ListRespGroupDetailViewModel> >
                            .Submit(json, Method.POST, urlEndPoint, Request);

                newDataSourceResult.Data  = query.data;
                newDataSourceResult.Total = query.total;

                foreach (var item in query.data)
                {
                    item.ID = EncryptionHelper.EncryptUrlParam(item.ID);
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }

            return(Json(newDataSourceResult));
        }
Пример #17
0
        public JsonResult DetailList([DataSourceRequest] DataSourceRequest request, string orgChangeID)
        {
            orgChangeID    = orgChangeID ?? (string)TempData.Peek("ID");
            TempData["ID"] = orgChangeID;

            // Must Convert to Json from kendo data source request , because filter using abstract class
            AjaxViewModel    jsonViewModel       = new AjaxViewModel();
            DataSourceResult newDataSourceResult = new DataSourceResult();

            try
            {
                var json     = Utilities.GridUtilities.ConvertKendoRequestToJson(request);
                var endpoint = url + "/GetDetailList/" + orgChangeID;

                var result = Utilities.RestAPIHelper <CustomDataSourceResult <ListOrgUnitChangeDetailViewModel> >
                             .Submit(json, Method.POST, endpoint);

                newDataSourceResult.Data  = result.data;
                newDataSourceResult.Total = result.total;
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(newDataSourceResult));
        }
Пример #18
0
        public JsonResult List([DataSourceRequest] DataSourceRequest request)
        {
            // Must Convert to Json from kendo data source request , because filter using abstract class
            AjaxViewModel    jsonViewModel       = new AjaxViewModel();
            DataSourceResult newDataSourceResult = new DataSourceResult();

            try
            {
                var json     = Utilities.GridUtilities.ConvertKendoRequestToJson(request);
                var endpoint = url + Route.Get;

                var result = Utilities.RestAPIHelper <CustomDataSourceResult <ListUserViewModel> >
                             .Submit(json, Method.POST, endpoint);

                newDataSourceResult.Data  = result.data;
                newDataSourceResult.Total = result.total;

                foreach (var item in result.data)
                {
                    item.ID = EncryptionHelper.EncryptUrlParam(item.ID);
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
                return(Json(jsonViewModel));
            }
            return(Json(newDataSourceResult));
        }
Пример #19
0
        public ActionResult DeleteRow(string id)
        {
            var ajaxViewModel = new AjaxViewModel();

            try
            {
                var endpoint = String.Format("{0}{1}Row/{2}", url, Route.Delete, id);
                Utilities.RestAPIHelper <string> .Submit("", Method.POST, endpoint);

                ajaxViewModel.SetValues(true, null, "Deleted Successfully");
            }
            catch (Exception ex)
            {
                ajaxViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }

            return(Json(ajaxViewModel));
        }
Пример #20
0
        public ActionResult Edit(CreateEditViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(model);
                var    endpoint = String.Format("{0}/ValidateCombination", url);
                var    isValid  = Utilities.RestAPIHelper <AjaxViewModel> .Submit(json, Method.POST, endpoint);

                if (!isValid.IsSuccess)
                {
                    jsonViewModel.SetValues(isValid.IsSuccess, null, isValid.Message);
                }
                else
                {
                    if (model.IsLegalEntity)
                    {
                        endpoint = String.Format("{0}/EditWithLegalEntity", url);
                        var content = Utilities.RestAPIHelper <CreateEditViewModel> .Submit(json, Method.PUT, endpoint);

                        jsonViewModel.SetValues(true, null, "Saved");
                    }
                    else
                    {
                        if (model.LegalEntityInformationID.HasValue)
                        {
                            endpoint = String.Format("{0}/DeleteLegalEntity/{1}", url, model.LegalEntityInformationID.GetValueOrDefault());

                            Utilities.RestAPIHelper <string> .Submit("", Method.DELETE, endpoint);
                        }
                        endpoint = url + Route.Edit;
                        var content = Utilities.RestAPIHelper <CreateEditViewModel> .Submit(json, Method.PUT, endpoint);

                        jsonViewModel.SetValues(true, null, "Saved");
                    }
                }
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
Пример #21
0
        public ActionResult CreateMenuDetail(CreateMenuDetailViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                var    decryptId = Convert.ToInt32(Utilities.EncryptionHelper.DecryptUrlParam(model.MenuID));
                string json      = JsonConvert.SerializeObject(model);
                var    endpoint  = menuDetailUrl + "/Add/" + decryptId;
                var    content   = Utilities.RestAPIHelper <CreateMenuDetailViewModel> .Submit(json, Method.POST, endpoint, Request);

                jsonViewModel.SetValues(true, null, "Saved");
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
Пример #22
0
        public ActionResult Delete(string[] arrayOfID)
        {
            var ajaxViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(arrayOfID);
                var    endpoint = String.Format("{0}{1}/{2}", url, Route.Delete, json);
                Utilities.RestAPIHelper <string> .Submit("", Method.POST, endpoint);

                ajaxViewModel.SetValues(true, null, "Deleted Successfully");
            }
            catch (Exception ex)
            {
                ajaxViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }

            return(Json(ajaxViewModel));
        }
Пример #23
0
        public JsonResult UpdateCurrentBussinessGroupID(EditCurrentBussinessGroupUserViewModel model)
        {
            AjaxViewModel jsonViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(model);
                var    endpoint = ApiUrl.SecurityUrl + "UpdateCurrentBussinessGroupID";
                Utilities.RestAPIHelper <EditCurrentBussinessGroupUserViewModel>
                .Submit(json, Method.POST, endpoint);

                jsonViewModel.SetValues(true, null, "CurrentBussinessGroupID has been updated");
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
Пример #24
0
        public ActionResult Delete(string[] arrayOfID)
        {
            var ajaxViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(arrayOfID);
                var    endpoint = url + Route.Delete + "/" + json;
                var    delete   = Utilities.RestAPIHelper <AjaxViewModel> .Submit("", Method.DELETE, endpoint);

                ajaxViewModel.SetValues(delete.IsSuccess, null, delete.Message);
            }
            catch (Exception ex)
            {
                ajaxViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }

            return(Json(ajaxViewModel));
        }
Пример #25
0
        public ActionResult NonActiveDetail(CreateEditDetailViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                string json = JsonConvert.SerializeObject(model);

                var endpoint = url + "/DeadActiveDetail";
                model = Utilities.RestAPIHelper <CreateEditDetailViewModel> .Submit(json, Method.PUT, endpoint);

                jsonViewModel.SetValues(true, null, "Saved");
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
Пример #26
0
        public ActionResult DeleteSpecification(string[] arrayOfID)
        {
            var ajaxViewModel = new AjaxViewModel();

            try
            {
                string json     = JsonConvert.SerializeObject(arrayOfID);
                var    endpoint = url + "/DeleteSpecification/" + json;
                Utilities.RestAPIHelper <string> .Submit("", Method.DELETE, endpoint, Request);

                ajaxViewModel.SetValues(true, null, "Deleted Successfully");
            }
            catch (Exception ex)
            {
                ajaxViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }

            return(Json(ajaxViewModel));
        }
Пример #27
0
        public ActionResult CreateLocation(CreateEditLocationViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                string json = JsonConvert.SerializeObject(model);

                var endpoint = String.Format("{0}/AddLocation/", url);
                var content  = Utilities.RestAPIHelper <CreateEditLocationViewModel>
                               .Submit(json, Method.POST, endpoint);

                jsonViewModel.SetValues(true, null, "Saved");
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
        public ActionResult Edit(CreateEditViewModel model)
        {
            var jsonViewModel = new AjaxViewModel();

            try
            {
                var decryptedID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.ID));
                model.ID = decryptedID.ToString();

                string json     = JsonConvert.SerializeObject(model);
                var    endpoint = url + Route.Edit;
                model = Utilities.RestAPIHelper <CreateEditViewModel>
                        .Submit(json, Method.PUT, endpoint);

                jsonViewModel.SetValues(true, null, "Saved");
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(Json(jsonViewModel));
        }
Пример #29
0
        public ActionResult Edit(string id)
        {
            var jsonViewModel         = new AjaxViewModel();
            CreateEditViewModel model = new CreateEditViewModel();

            try
            {
                int decryptID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(id));
                var endpoint  = String.Format("{0}{1}/{2}", url, Route.Get, decryptID);
                model = Utilities.RestAPIHelper <CreateEditViewModel> .Submit("", Method.GET, endpoint);
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(PartialView("CreateEdit", model));
        }
Пример #30
0
        public IActionResult IndexDetail(string id)
        {
            var jsonViewModel = new AjaxViewModel();
            var model         = new IndexDetailViewModel();

            try
            {
                int decryptID = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(id));
                var endpoint  = url + "/GetDetailIndex/" + decryptID;
                model = Utilities.RestAPIHelper <IndexDetailViewModel> .Submit("", Method.GET, endpoint);
            }
            catch (Exception ex)
            {
                jsonViewModel.SetValues(false, null, String.Format("Failed\\nMessage: {0}", ex.GetBaseException().Message));
            }
            return(View(model));
        }