// Calling the method of using Async //public int test() { // int task = Insert().Result; // return task; //} public int InsertTask(Hr_Experiences objInsert) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); //int result = Insert(objInsert).Result; //return result; int RowEffected = 0; try { if (objInsert != null) { OpenEntityConnection(); objInsert.InsDate = DateTime.Now;//DateTime.Today; objPharmaEntities.Hr_Experiences.Add(objInsert); RowEffected = objPharmaEntities.SaveChanges(); } } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); RowEffected = -1; ex.InnerException.Message.ToString(); } finally { CloseEntityConnection(); } return(RowEffected); }
public Hr_Experiences GetById(string Experience_ID) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); try { OpenEntityConnection(); Hr_Experiences ExperiencesForGetEntity = (from objLinq in objPharmaEntities.Hr_Experiences where objLinq.Experience_Id == Experience_ID && objLinq.Rec_Status == 0 select objLinq).FirstOrDefault(); return(ExperiencesForGetEntity); } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); ex.InnerException.Message.ToString(); return(null); } finally { CloseEntityConnection(); } }
public bool UpdateTask(Hr_Experiences objUpdate) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); // bool task = Update(objInsert).Result; //return task; int rowEffected = 0; try { if (objUpdate != null) //Definsive Programming { OpenEntityConnection(); Hr_Experiences ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Experiences where objLinq.Experience_Id == objUpdate.Experience_Id select objLinq).FirstOrDefault(); if (ObjForUpdate != null) { ObjForUpdate.Experience_Code = objUpdate.Experience_Code; ObjForUpdate.Experience_Name = objUpdate.Experience_Name; ObjForUpdate.Experience_NameEn = objUpdate.Experience_NameEn; ObjForUpdate.ExperienceCategory_Id = objUpdate.ExperienceCategory_Id; ObjForUpdate.UpdateUser = objUpdate.UpdateUser; ObjForUpdate.UpdateDate = DateTime.Now; rowEffected = objPharmaEntities.SaveChanges(); } } } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); rowEffected = -1; ex.InnerException.Message.ToString(); } finally { CloseEntityConnection(); } if (rowEffected > 0) { return(true); } else { return(false); } }
public async Task <bool> Delete(Hr_Experiences objDelete) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); int rowEffected = 0; try { if (objDelete != null) //Definsive Programming { OpenEntityConnection(); Hr_Experiences objForDelete = (from objLinq in objPharmaEntities.Hr_Experiences where objLinq.Experience_Id == objDelete.Experience_Id select objLinq).FirstOrDefault(); objForDelete.Rec_Status = 1; objForDelete.DeleteUser = objDelete.DeleteUser; objForDelete.DeleteDate = DateTime.Now; rowEffected = await objPharmaEntities.SaveChangesAsync(); } } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); rowEffected = -1; ex.InnerException.Message.ToString(); } finally { CloseEntityConnection(); } if (rowEffected > 0) { return(true); } else { return(false); } }