public Hr_Grades GetById(string Grade_ID) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); try { OpenEntityConnection(); Hr_Grades GradesForGetEntity = (from objLinq in objPharmaEntities.Hr_Grades where objLinq.Grade_Id == Grade_ID && objLinq.Rec_Status == 0 select objLinq).FirstOrDefault(); return GradesForGetEntity; } 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 async Task<int> Insert(Hr_Grades objInsert) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); int RowEffected = 0; try { if (objInsert != null) { OpenEntityConnection(); objInsert.InsDate = DateTime.Now;//DateTime.Today; objPharmaEntities.Hr_Grades.Add(objInsert); 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(); } return RowEffected; }
public async Task<bool> Update(Hr_Grades objUpdate) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); int rowEffected = 0; try { if (objUpdate != null) //Definsive Programming { OpenEntityConnection(); Hr_Grades ObjForUpdate = (from objLinq in objPharmaEntities.Hr_Grades where objLinq.Grade_Id == objUpdate.Grade_Id select objLinq).FirstOrDefault(); ObjForUpdate.Grade_Name = objUpdate.Grade_Name; ObjForUpdate.Grade_NameEn = objUpdate.Grade_NameEn; ObjForUpdate.Grade_Code = objUpdate.Grade_Code; ObjForUpdate.UpdateUser = objUpdate.UpdateUser; ObjForUpdate.UpdateDate = 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; }
public bool DeleteTask(Hr_Grades objDelete) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); // bool task = Delete(objInsert).Result; // return task; int rowEffected = 0; try { if (objDelete != null) //Definsive Programming { OpenEntityConnection(); Hr_Grades objForDelete = (from objLinq in objPharmaEntities.Hr_Grades where objLinq.Grade_Id == objDelete.Grade_Id select objLinq).FirstOrDefault(); objForDelete.Rec_Status = 1; objForDelete.DeleteUser = objDelete.DeleteUser; objForDelete.DeleteDate = 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; }