public bool SetRolesAuth(OSS_ROLES_AUTH ROLEAUTH) { try { OSS_ROLES_AUTH TU = _context.OSS_ROLES_AUTH.Where(t => t.U_Role == ROLEAUTH.U_Role).FirstOrDefault(); if (TU != null) { TU.U_Role = ROLEAUTH.U_Role; TU.U_Component = ROLEAUTH.U_Component; _context.OSS_ROLES_AUTH.Update(TU); _context.SaveChanges(); return(true); } string Query = "select ISNULL(cast(max(cast(Code as int)+1)as nvarchar),'1') as Code from [@OSS_ROLES_AUTH]"; //MaxCode = _context.Database.SqlQuery<int>(Query).SingleOrDefault(); var MaxCodeStr = _context.OSS_ROLES_AUTH.FromSqlRaw(Query).Select(t => t.Code).FirstOrDefault(); ROLEAUTH.Code = MaxCodeStr; ROLEAUTH.Name = MaxCodeStr; //newRLAth.U_Role = ROLEAUTH.U_Role; //newRLAth.U_Component = ROLEAUTH.U_Component; ROLEAUTH.U_Method = ""; _context.OSS_ROLES_AUTH.Add(ROLEAUTH); _context.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public Boolean Save(Email eml) { try { EmailLog emlLog = new EmailLog(); emlLog.Code = eml.Code; emlLog.Name = emlLog.Code; emlLog.U_Attempt = 1; emlLog.U_Subject = eml.Subject; emlLog.U_Body = eml.Body; emlLog.U_EmlFrm = ""; emlLog.U_EmlTO = eml.To; if (eml.IsBodyHTML == true) { emlLog.U_IsHTML = "1"; } else { emlLog.U_IsHTML = "0"; } if (eml.IsBodyHTML == true) { emlLog.U_Subject = eml.Subject; } emlLog.U_CrtdBy = eml.User; emlLog.U_CrtdDt = DateTime.Now; if (eml.IsQueue == true) { emlLog.U_IsQ = "1"; } else { emlLog.U_IsQ = "0"; } if (eml.IsSent == true) { emlLog.U_IsSent = "1"; } else { emlLog.U_IsSent = "0"; } emlLog.U_FailedReason1 = eml.FailedReason; _context.EmailLog.Add(emlLog); _context.SaveChanges(); //return true; return(true); } catch (Exception ex) { return(false); } }
public bool PostMISData(MISUploadVM VM) { try { if (VM.Type == "Monthly") { foreach (var LN in VM.Lines) { OSS_MIS_Monthly OBJ = new OSS_MIS_Monthly(); OBJ = _context.OSS_MIS_Monthly.Where(t => t.FY_Year == LN.FY_Year && t.Period == LN.Period && t.Card_Code == LN.Card_Code && t.GL_Code == LN.GL_Code).FirstOrDefault(); if (OBJ != null) { _context.Entry <OSS_MIS_Monthly>(OBJ).State = EntityState.Detached; } if (OBJ == null) { OSS_MIS_Monthly OBJ2 = new OSS_MIS_Monthly(); OBJ2.FY_Year = LN.FY_Year; OBJ2.Period = LN.Period; OBJ2.Card_Code = LN.Card_Code; OBJ2.GL_Code = LN.GL_Code; OBJ2.Amt = LN.Amt; _context.OSS_MIS_Monthly.Add(OBJ2); _context.SaveChanges(); } else { OBJ.Amt = LN.Amt; _context.OSS_MIS_Monthly.Update(OBJ); _context.SaveChanges(); } } } else if (VM.Type == "Quarterly") { foreach (var LN in VM.Lines) { OSS_MIS_Quaterly OBJ = new OSS_MIS_Quaterly(); OBJ = _context.OSS_MIS_Quaterly.Where(t => t.FY_Year == LN.FY_Year && t.Period == LN.Period && t.Card_Code == LN.Card_Code && t.GL_Code == LN.GL_Code).FirstOrDefault(); if (OBJ != null) { _context.Entry <OSS_MIS_Quaterly>(OBJ).State = EntityState.Detached; } if (OBJ == null) { OSS_MIS_Quaterly OBJ2 = new OSS_MIS_Quaterly(); OBJ2.FY_Year = LN.FY_Year; OBJ2.Period = LN.Period; OBJ2.Card_Code = LN.Card_Code; OBJ2.GL_Code = LN.GL_Code; OBJ2.Amt = LN.Amt; _context.OSS_MIS_Quaterly.Add(OBJ2); _context.SaveChanges(); } else { OBJ.Amt = LN.Amt; _context.OSS_MIS_Quaterly.Update(OBJ); _context.SaveChanges(); } } } else if (VM.Type == "Yearly") { foreach (var LN in VM.Lines) { OSS_MIS_Yearly OBJ = new OSS_MIS_Yearly(); OBJ = _context.OSS_MIS_Yearly.Where(t => t.FY_Year == LN.FY_Year && t.Period == LN.Period && t.Card_Code == LN.Card_Code && t.GL_Code == LN.GL_Code).FirstOrDefault(); if (OBJ != null) { _context.Entry <OSS_MIS_Yearly>(OBJ).State = EntityState.Detached; } if (OBJ == null) { OSS_MIS_Yearly OBJ2 = new OSS_MIS_Yearly(); OBJ2.FY_Year = LN.FY_Year; OBJ2.Period = LN.Period; OBJ2.Card_Code = LN.Card_Code; OBJ2.GL_Code = LN.GL_Code; OBJ2.Amt = LN.Amt; _context.OSS_MIS_Yearly.Add(OBJ2); _context.SaveChanges(); } else { OBJ.Amt = LN.Amt; _context.OSS_MIS_Yearly.Update(OBJ); _context.SaveChanges(); } } } } catch (Exception E) { return(false); } return(true); }