public JsonResult DeleteEvent(Event e) { var status = false; try { using (HRAlign_InlandEntities1 dc = new HRAlign_InlandEntities1()) { if (e.EventID > 0) { //Update the deleted event as "N" var v = dc.Events.Where(a => a.EventID == e.EventID).FirstOrDefault(); if (v != null) { v.deleteActive = "N"; } } dc.SaveChanges(); status = true; } return(new JsonResult { Data = new { status = status } }); } catch (Exception ex) { throw ex; } }
public JsonResult GetEvents() { string strReq = ""; strReq = Session["Empcd"].ToString(); string[] arrEmpcd; string[] arrBrcd; string[] arrMsgs; strReq = strReq.Replace("%2f", "/"); strReq = strReq.Replace("%3F", ""); strReq = strReq.Replace("%2F", "/"); strReq = strReq.Replace("%2B", "+"); strReq = EncryDecry.Decrypt(strReq); if (strReq != null) { arrMsgs = strReq.Split('&'); } else { arrMsgs = null; } arrEmpcd = arrMsgs[0].Split('='); string emp = arrEmpcd[1].ToString().Trim(); arrBrcd = arrMsgs[1].Split('='); string Brcd = arrBrcd[1].ToString().Trim(); try { using (HRAlign_InlandEntities1 dc = new HRAlign_InlandEntities1()) { var events = dc.Events.Where(x => x.Empcd == emp & x.deleteActive == "Y").ToList(); return(new JsonResult { Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } catch (Exception ex) { throw ex; } }
public JsonResult SaveEvent(Event e) { string strReq = ""; strReq = Session["Empcd"].ToString(); string[] arrEmpcd; string[] arrMsgs; strReq = strReq.Replace("%2f", "/"); strReq = strReq.Replace("%3F", ""); strReq = strReq.Replace("%2F", "/"); strReq = strReq.Replace("%2B", "+"); strReq = EncryDecry.Decrypt(strReq); if (strReq != null) { arrMsgs = strReq.Split('&'); } else { arrMsgs = null; } arrEmpcd = arrMsgs[0].Split('='); string emp = arrEmpcd[1].ToString().Trim(); var status = false; try { using (HRAlign_InlandEntities1 dc = new HRAlign_InlandEntities1()) { if (e.EventID > 0) { //Update the event var v = dc.Events.Where(a => a.EventID == e.EventID).FirstOrDefault(); if (v != null) { v.Subject = e.Subject; v.Start = e.Start; v.End = e.End; v.Description = e.Description; v.IsFullDay = e.IsFullDay; v.ThemeColor = e.ThemeColor; v.Empcd = emp; v.deleteActive = "Y"; } } else { e.deleteActive = "Y"; e.Empcd = emp; dc.Events.Add(e); } dc.SaveChanges(); status = true; } } catch (Exception) { throw; } return(new JsonResult { Data = new { status = status } }); }