public ActionResult GetHdReqInfoDetail(int hdReqId) { MessageViewModels response = new MessageViewModels(); HelpdeskRequest hdRequest = _hdReqServices.FindById(hdReqId); if (null != hdRequest) { HdReqDetailInfo hdReqDetailInfo = new HdReqDetailInfo(); hdReqDetailInfo.SelectedHdSrvCatId = hdRequest.HelpdeskRequestCatId.Value; List <HelpdeskRequestCategory> hdSrvCats = _helpdeskServiceCat.GetAll(); List <HelpdeskServiceCatModel> hdSrvCatModels = new List <HelpdeskServiceCatModel>(); HelpdeskServiceCatModel hdSrvCatModel = null; foreach (var cat in hdSrvCats) { hdSrvCatModel = new HelpdeskServiceCatModel(); hdSrvCatModel.Id = cat.Id; hdSrvCatModel.Name = cat.Name; hdSrvCatModels.Add(hdSrvCatModel); } List <HelpdeskRequestCategory> hdServices = _helpdeskServiceCat.GetAll(); List <HelpdeskServiceModel> hdReqModels = new List <HelpdeskServiceModel>(); HelpdeskServiceModel hdSrvModel = null; foreach (var hdSrv in hdServices) { hdSrvModel = new HelpdeskServiceModel(); hdSrvModel.Id = hdSrv.Id; hdSrvModel.Name = hdSrv.Name; hdReqModels.Add(hdSrvModel); } HelpdeskRequestModel hdReqModel = new HelpdeskRequestModel(); hdReqModel.HdReqTitle = hdRequest.Title; hdReqModel.HdReqUserDesc = hdRequest.Description; hdReqDetailInfo.HdSrvCategories = hdSrvCatModels; hdReqDetailInfo.ListHdSrvBySelectedCat = hdReqModels; hdReqDetailInfo.HdReqInfoDetail = hdReqModel; response.Data = hdReqDetailInfo; } else { response.StatusCode = -1; response.Msg = "Not found !"; } return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult ManageRequest() { String action = this.Request.QueryString["action"]; if (null != action) { String url = ""; if (action.Equals("loadHdSrvCat")) { // Start load all service category List <HelpdeskRequestCategory> hdSrvCategories = _helpdeskServiceCatService.GetAll(); List <HelpdeskServiceCatModel> hdSrvCats = new List <HelpdeskServiceCatModel>(); HelpdeskServiceCatModel hdSrvCat = null; for (var i = 0; i < hdSrvCategories.Capacity; i++) { hdSrvCat = new HelpdeskServiceCatModel(); hdSrvCat.Id = hdSrvCategories[i].Id; hdSrvCat.Name = hdSrvCategories[i].Name; hdSrvCats.Add(hdSrvCat); } HelpdeskSerivceCatListModel hdSrvCatListModel = new HelpdeskSerivceCatListModel(hdSrvCats); // Start load all service category return(Json(hdSrvCatListModel, JsonRequestBehavior.AllowGet)); } else if (action.Equals("hdSrvCatDetail")) { NameValueCollection nvc = this.Request.QueryString; String idStr = nvc["id"]; MessageViewModels response = new MessageViewModels(); try { int id = Int32.Parse(idStr); HelpdeskRequestCategory hdSrvCategory = _helpdeskServiceCatService.FindById(id); if (null != hdSrvCategory) { HelpdeskServiceCatModel catModel = new HelpdeskServiceCatModel(); catModel.Id = hdSrvCategory.Id; catModel.Name = hdSrvCategory.Name; response.Data = catModel; } else { response.StatusCode = 4; response.Msg = "Không tìm thấy nhóm dịch vụ hỗ trợ."; } return(Json(response, JsonRequestBehavior.AllowGet)); } catch (Exception) { response.StatusCode = -1; return(Json(response)); } } else if (action.Equals("loadHdSrvCatTable")) { url = "_helpdeskServiceCategoryTablePartial"; ViewBag.helpdeskServiceCategories = _helpdeskServiceCatService.GetAll(); } else if (action.Equals("searchHdSrvCategory")) { url = "_helpdeskServiceCategoryTablePartial"; NameValueCollection nvc = this.Request.Form; string name = nvc["searchStrHdSrvCat"]; ViewBag.helpdeskServiceCategories = _helpdeskServiceCatService.FindByName(name); } else if (action.Equals("addHdSrvCategory")) { NameValueCollection nvc = this.Request.Form; String name = nvc["hdSrvCatName"]; HelpdeskRequestCategory hdSrvCategory = new HelpdeskRequestCategory(); hdSrvCategory.Name = name; _helpdeskServiceCatService.Add(hdSrvCategory); MessageViewModels response = new MessageViewModels(); return(Json(response)); } else if (action.Equals("updateHdSrvCategory")) { NameValueCollection nvc = this.Request.Form; String name = nvc["hdSrvCatName"]; String idStr = nvc["hdSrvCatId"]; MessageViewModels response = new MessageViewModels(); try { int id = Int32.Parse(idStr); HelpdeskRequestCategory hdSrvCategory = _helpdeskServiceCatService.FindById(id); if (hdSrvCategory != null) { hdSrvCategory.Name = name; _helpdeskServiceCatService.Update(hdSrvCategory); } else { response.StatusCode = 4; response.Msg = "Không tìm thấy nhóm dịch vụ hỗ trợ."; } return(Json(response)); } catch (Exception) { response.StatusCode = -1; response.Msg = "Lỗi cập nhật nhóm dịch vụ hỗ trợ."; return(Json(response)); } } else if (action.Equals("delHdSrvCategory")) { MessageViewModels response = new MessageViewModels(); NameValueCollection nvc = this.Request.Form; string idStrList = nvc["hdSrvCatDeletedList"]; List <string> ids = idStrList.Split(',').ToList(); if (ids.Count != 0) { foreach (var id in ids) { try { HelpdeskRequestCategory s = _helpdeskServiceCatService.FindById(Int32.Parse(id)); if (null != s) { _helpdeskServiceCatService.Delete(s); } } catch (Exception exception) { response.StatusCode = -1; return(Json(response)); } } response.Msg = "OK !"; } else { response.StatusCode = -1; } return(Json(response)); } return(PartialView(url)); } return(View("~/Views/Config/ManageHelpdeskServiceCategory.cshtml")); }