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