// Calling the method of using Async public int InsertTask(APP_Menus objInsert) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); // int task = Insert(objInsert).Result; /// return task; int RowEffected = 0; try { if (objInsert != null) { OpenEntityConnection(); objPharmaEntities.APP_Menus.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 APP_Menus GetById(string Rec_ID) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); try { OpenEntityConnection(); APP_Menus objectForGetEntity = (from objLinq in objPharmaEntities.APP_Menus where objLinq.MenuId == Rec_ID select objLinq).FirstOrDefault(); return(objectForGetEntity); } 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(APP_Menus objUpdate) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); // bool task = Update(objUpdate).Result; // return task; int rowEffected = 0; try { if (objUpdate != null) //Definsive Programming { OpenEntityConnection(); APP_Menus ObjForUpdate = (from objLinq in objPharmaEntities.APP_Menus where objLinq.MenuId == objUpdate.MenuId select objLinq).FirstOrDefault(); ObjForUpdate.MenuName = objUpdate.MenuName; ObjForUpdate.MenuNameEn = objUpdate.MenuNameEn; 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(APP_Menus objDelete) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); int rowEffected = 0; try { OpenEntityConnection(); if (objDelete != null) //Definsive Programming { APP_Menus objForDelete = (from objLinq in objPharmaEntities.APP_Menus where objLinq.MenuId == objDelete.MenuId select objLinq).FirstOrDefault(); objForDelete.isActive = 0; 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); } }