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