public static void Insert(object model) { //Type type = model.GetType(); //string propName = type.Name; //var property = type.GetProperty(propName); //var propertyValue = property.GetValue(model); Type type = model.GetType(); foreach (PropertyInfo prop in type.GetProperties()) { if (prop.Name == "GUID") { Int64 guid = KasifHelper.GuidFactory(); prop.SetValue(model, guid); } else if (prop.Name == "STATUS") { prop.SetValue(model, Convert.ToInt16(1)); } else if (prop.Name == "LASTUPDATED") { prop.SetValue(model, KasifHelper.GetCurrentDate()); } } DbAction(context => { context.Entry(model).State = EntityState.Added; context.SaveChanges(); }); }
private void DoChangePwd() { try { List <USER_USER> lstUser = new List <USER_USER>(); USER_USER usrObj = new USER_USER(); DbOperations.FindBy <USER_USER>(ref lstUser, usrObj, x => x.GUID == KsfSI.UserGuid); lstUser[0].PASSWORD = KasifHelper.GetSha512HashedData(txtNewPwd.Value); lstUser[0].LAST_PWD_CHANGE_DATE = KasifHelper.GetCurrentDate(); DbOperations.Update(lstUser[0]); } catch (Exception ex) { throw ex; } }
public static void Delete(object model) { Type type = model.GetType(); foreach (PropertyInfo prop in type.GetProperties()) { if (prop.Name == "STATUS") { prop.SetValue(model, Convert.ToInt16(0)); } else if (prop.Name == "LASTUPDATED") { prop.SetValue(model, KasifHelper.GetCurrentDate()); } } DbAction(context => { context.Entry(model).State = EntityState.Modified; context.SaveChanges(); }); }