public ActionResult AddHdRequest(HelpdeskRequestModel request) { MessageViewModels response = new MessageViewModels(); try { User u = _userServices.FindById(request.HdReqUserId); HelpdeskRequestCategory hdServiceCat = _helpdeskServiceCat.FindById(request.HdServiceCatId); if (u != null && hdServiceCat != null) { HelpdeskRequest hdRequest = new HelpdeskRequest(); hdRequest.HelpdeskRequestCatId = request.HdServiceCatId; hdRequest.HouseId = u.HouseId;//AnTT them vao cho nay 27-5-2016 hdRequest.CreateDate = DateTime.Now; hdRequest.Description = request.HdReqUserDesc; hdRequest.ModifyDate = DateTime.Now; hdRequest.Status = (int)StatusEnum.Open; hdRequest.Title = request.HdReqTitle; int id = _hdReqServices.Add(hdRequest); HelpdeskRequestLog log = new HelpdeskRequestLog(); log.ChangeFromUserId = u.Id; log.AssignToUserId = u.Id; log.HelpdeskRequestId = id; log.StatusFrom = (int)StatusEnum.Open; log.StatusTo = (int)StatusEnum.Open; log.CreateDate = DateTime.Now; _helpdeskRequestLogServices.Add(log); } else { response.StatusCode = -1; } } catch (Exception e) { Console.WriteLine(e.StackTrace); response.StatusCode = -1; return(Json(response));; } return(Json(response)); }
public ActionResult UpdateHdRequest(HelpdeskRequestModel request) { try { User u = _userServices.FindById(request.HdReqUserId); HelpdeskRequest hdRequest = _hdReqServices.FindById(request.HdReqId); if (u != null && hdRequest != null) { HelpdeskRequestCategory hdServiceCat = _helpdeskServiceCat.FindById(request.HdServiceCatId); hdRequest.HelpdeskRequestCatId = hdServiceCat.Id; hdRequest.Title = request.HdReqTitle; hdRequest.Description = request.HdReqUserDesc; hdRequest.ModifyDate = DateTime.Now; _hdReqServices.Update(hdRequest); return(RedirectToAction("ViewHdRequestDetail", new { hdReqId = hdRequest.Id, userId = u.Id })); } // return to homepage } catch (Exception e) { return(RedirectToAction("ViewHistoryHdRequest")); } return(RedirectToAction("ViewHistoryHdRequest")); }
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")); }
public void Delete(HelpdeskRequestCategory hdReqCategory) { helpdeskRequestCatRepository.Delete(hdReqCategory); }
public void Update(HelpdeskRequestCategory hdReqCategory) { helpdeskRequestCatRepository.Update(hdReqCategory); }
public void Add(HelpdeskRequestCategory hdReqCategory) { helpdeskRequestCatRepository.Add(hdReqCategory); }