public ActionResult Create(T_CMS_Static_ContractTerm model) { try { if (ModelState.IsValid) { // model.CreatedUser = CurrentUser.UserName; if (model.ID != 0) { //get default value // T_CMS_Static_ContractTerm b = T_CMS_Static_ContractTermManager.GetById(model.ID); T_CMS_Static_ContractTermManager.Update(model); } else { // TODO: Add insert logic here // model.CreatedDate = SystemConfig.CurrentDate; T_CMS_Static_ContractTermManager.Add(model); } return(View(ViewFolder + "list.cshtml", T_CMS_Static_ContractTermManager.GetAll())); } } catch { return(View(model)); } return(View(model)); }
public static void RemoveCache(T_CMS_Static_ContractTerm 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); }
public ContentResult Save(string objdata, string value) { JsonObject js = new JsonObject(); js.StatusCode = 200; js.Message = "Upload Success"; try { T_CMS_Static_ContractTerm obj = JsonConvert.DeserializeObject <T_CMS_Static_ContractTerm>(objdata); obj = T_CMS_Static_ContractTermManager.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")); }
/// <summary> /// use for setting up default value /// </summary> /// <returns></returns> public ActionResult Update(int ID, string TargetID = "T_CMS_Static_ContractTermlist") { T_CMS_Static_ContractTerm objItem = T_CMS_Static_ContractTermManager.GetById(ID); objItem.TargetDisplayID = TargetID; return(View(ViewFolder + "Create.cshtml", objItem)); }
public static void Delete(T_CMS_Static_ContractTerm 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_CMS_Static_ContractTerm Update(T_CMS_Static_ContractTerm objItem) { T_CMS_Static_ContractTerm item = new T_CMS_Static_ContractTerm(); 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_CMS_Static_ContractTerm>().GetAwaiter().GetResult(); RemoveCache(item); } } return(item); }
public static T_CMS_Static_ContractTerm Add(T_CMS_Static_ContractTerm objItem) { T_CMS_Static_ContractTerm b = new T_CMS_Static_ContractTerm(); using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.PostAsJsonAsync(Resource, objItem).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { b = response.Content.ReadAsAsync <T_CMS_Static_ContractTerm>().GetAwaiter().GetResult(); } } RemoveCache(b); return(b); }
public ActionResult Update(T_CMS_Static_ContractTerm model) { try { if (ModelState.IsValid) { // TODO: Add insert logic here T_CMS_Static_ContractTermManager.Update(model); //return RedirectToAction("Index"); } return(View(model)); } catch { return(View(model)); } }
public static T_CMS_Static_ContractTerm GetById(int id) { string key = String.Format(SETTINGS_ID_KEY, id); object obj2 = HttpCache.Get(key); if (obj2 != null) { return((T_CMS_Static_ContractTerm)obj2); } T_CMS_Static_ContractTerm b = new T_CMS_Static_ContractTerm(); 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_CMS_Static_ContractTerm>().GetAwaiter().GetResult(); } } HttpCache.Max(key, b); return(b); }
// 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_CMS_Static_ContractTerm Put(string id, [FromBody] T_CMS_Static_ContractTerm value) { return(T_CMS_Static_ContractTermManager.UpdateItem(value)); }
// POST api/<controller> /// <summary> /// Posts the specified value. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public T_CMS_Static_ContractTerm Post([FromBody] T_CMS_Static_ContractTerm value) { return(T_CMS_Static_ContractTermManager.AddItem(value)); }
public ActionResult Get(int ID, string action) { T_CMS_Static_ContractTerm objItem = T_CMS_Static_ContractTermManager.GetById(ID); return(Content(JsonConvert.SerializeObject(objItem), "application/json")); }
public ActionResult Get(int ID) { T_CMS_Static_ContractTerm objItem = T_CMS_Static_ContractTermManager.GetById(ID); return(View(objItem)); }