public ContentResult Save(string objdata, string value) { JsonObject js = new JsonObject(); js.StatusCode = 200; js.Message = "Upload Success"; try { T_LMS_Trans_LeaveStory obj = JsonConvert.DeserializeObject <T_LMS_Trans_LeaveStory>(objdata); obj = T_LMS_Trans_LeaveStoryManager.Update(obj); if (obj.Id == 0) { js.StatusCode = 400; js.Message = "Has Errors. Please contact Admin for more information"; } else { js.Data = obj; } } catch (Exception objEx) { js.StatusCode = 400; js.Message = objEx.Message; } return(Content(JsonConvert.SerializeObject(js), "application/json")); }
public ActionResult Create(T_LMS_Trans_LeaveStory model) { try { if (ModelState.IsValid) { // model.CreatedUser = CurrentUser.UserName; if (model.Id != 0) { //get default value // T_LMS_Trans_LeaveStory b = T_LMS_Trans_LeaveStoryManager.GetById(model.Id); T_LMS_Trans_LeaveStoryManager.Update(model); } else { // TODO: Add insert logic here // model.CreatedDate = SystemConfig.CurrentDate; T_LMS_Trans_LeaveStoryManager.Add(model); } return(View(ViewFolder + "list.cshtml", T_LMS_Trans_LeaveStoryManager.GetAll())); } } catch { return(View(model)); } return(View(model)); }
public static void RemoveCache(T_LMS_Trans_LeaveStory objItem) { HttpCache.RemoveByPattern(SETTINGS_ALL_KEY); HttpCache.RemoveByPattern(string.Format(SETTINGS_ID_KEY, objItem.Id)); //HttpCache.RemoveByPattern(string.Format(SETTINGS_User_KEY, objItem.CreatedUser)); HttpCache.RemoveSearchCache(SystemConfig.AllowSearchCache, SETTINGS_Search_KEY); }
/// <summary> /// use for setting up default value /// </summary> /// <returns></returns> public ActionResult Update(int Id, string TargetID = "T_LMS_Trans_LeaveStorylist") { T_LMS_Trans_LeaveStory objItem = T_LMS_Trans_LeaveStoryManager.GetById(Id); objItem.TargetDisplayID = TargetID; return(View(ViewFolder + "Create.cshtml", objItem)); }
public static void Delete(T_LMS_Trans_LeaveStory objItem) { if (objItem != null) { using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.DeleteAsync(string.Format(Resource + "/{0}", objItem.Id)).GetAwaiter().GetResult(); } RemoveCache(objItem); } }
public static T_LMS_Trans_LeaveStory Update(T_LMS_Trans_LeaveStory objItem) { T_LMS_Trans_LeaveStory item = new T_LMS_Trans_LeaveStory(); using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.PutAsJsonAsync(string.Format(Resource + "/{0}", objItem.Id), objItem).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { item = response.Content.ReadAsAsync <T_LMS_Trans_LeaveStory>().GetAwaiter().GetResult(); RemoveCache(item); } } return(item); }
public static T_LMS_Trans_LeaveStory Add(T_LMS_Trans_LeaveStory objItem) { T_LMS_Trans_LeaveStory b = new T_LMS_Trans_LeaveStory(); using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.PostAsJsonAsync(Resource, objItem).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { b = response.Content.ReadAsAsync <T_LMS_Trans_LeaveStory>().GetAwaiter().GetResult(); } } RemoveCache(b); return(b); }
public ActionResult Update(T_LMS_Trans_LeaveStory model) { try { if (ModelState.IsValid) { // TODO: Add insert logic here T_LMS_Trans_LeaveStoryManager.Update(model); //return RedirectToAction("Index"); } return(View(model)); } catch { return(View(model)); } }
public ContentResult abc(T_LMS_Trans_LeaveStory item) { ////string b = Request["item"]; ////IEnumerable<T_LMS_Trans_LeaveStory> objItemList = JsonConvert.DeserializeObject<IEnumerable<T_LMS_Trans_LeaveStory>>(item); //JsonObject obj = new JsonObject(); //obj.StatusCode = 200; //obj.Message = "The process is sucessed"; ////foreach (T_LMS_Trans_LeaveStory objitem in objItemList) ////{ //// //default value //// //objitem.CreatedUser = CurrentUser.UserName; //// objitem.CreatedDate = SystemConfig.CurrentDate; //// T_LMS_Trans_LeaveStoryManager.Add(objitem); ////} //return Content(JsonConvert.SerializeObject(obj), "application/json"); return(Content("test 1")); }
public static T_LMS_Trans_LeaveStory GetById(int id) { string key = String.Format(SETTINGS_ID_KEY, id); object obj2 = HttpCache.Get(key); if (obj2 != null) { return((T_LMS_Trans_LeaveStory)obj2); } T_LMS_Trans_LeaveStory b = new T_LMS_Trans_LeaveStory(); using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.GetAsync(string.Format(Resource + "?Id={0}", id)).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { b = response.Content.ReadAsAsync <T_LMS_Trans_LeaveStory>().GetAwaiter().GetResult(); } } HttpCache.Max(key, b); return(b); }
public ActionResult Get(int Id) { T_LMS_Trans_LeaveStory objItem = T_LMS_Trans_LeaveStoryManager.GetById(Id); return(View(objItem)); }
public ActionResult Get(int Id, string action) { T_LMS_Trans_LeaveStory objItem = T_LMS_Trans_LeaveStoryManager.GetById(Id); return(Content(JsonConvert.SerializeObject(objItem), "application/json")); }
// PUT api/<controller>/5 /// <summary> /// Puts the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <param name="value">The value.</param> /// <returns></returns> /// <exception cref="HttpResponseException"></exception> public T_LMS_Trans_LeaveStory Put(string id, [FromBody] T_LMS_Trans_LeaveStory value) { return(T_LMS_Trans_LeaveStoryManager.UpdateItem(value)); }
// POST api/<controller> /// <summary> /// Posts the specified value. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public T_LMS_Trans_LeaveStory Post([FromBody] T_LMS_Trans_LeaveStory value) { return(T_LMS_Trans_LeaveStoryManager.AddItem(value)); }