/// <summary> /// Deleting entity by its id /// </summary> /// <param name="id">Id of particular entity</param> /// <param name="contextEntity">Instance of the context class</param> public void DeleteById(object id) { using (TLFCSEntities context = BaseContext.GetDbContext()) { Delete(FindById(id)); } }
public static string GenerateLink(int TicketId) { TLFCSEntities _dbContext = new TLFCSEntities(); string Link = RandomNumber(9, 900000); int EmployeeId = _dbContext.CS_Ticket.Where(c => c.TicketId == TicketId).Select(c => c.EmployeeId).SingleOrDefault(); string strEmployee = EmployeeId.ToString(); if (strEmployee.Length < 2) { strEmployee = "000" + strEmployee; } else if (strEmployee.Length < 3) { strEmployee = "00" + strEmployee; } else if (strEmployee.Length < 4) { strEmployee = "0" + strEmployee; } Link = Link + strEmployee; Link = Encrypt(Link); Link = Link.Replace((char)47, 'D'); return(Link); }
/// <summary> /// Find entity by id /// </summary> /// <param name="id">Id of the respective entity</param> /// <returns>Entity data</returns> public T FindById(object id) { using (TLFCSEntities context = BaseContext.GetDbContext()) { DbSet <T> table = context.Set <T>(); return(table.Find(id)); } }
/// <summary> /// Get all data of respective entity /// </summary> /// <returns>Get data of respective entity into list </returns> public IEnumerable <T> GetAll() { using (TLFCSEntities context = BaseContext.GetDbContext()) { DbSet <T> table = context.Set <T>(); return(table.ToList()); } }
/// <summary> /// Inserting entity /// </summary> /// <param name="insertEntity">Instance of the entity</param> public void Insert(T insertEntity) { using (TLFCSEntities context = BaseContext.GetDbContext()) { DbSet <T> table = context.Set <T>(); table.Add(insertEntity); context.SaveChanges(); } }
/// <summary> /// Deleting entity /// </summary> /// <param name="deleteEntity">Instance of the entity</param> public void Delete(T deleteEntity) { using (TLFCSEntities context = BaseContext.GetDbContext()) { DbSet <T> table = context.Set <T>(); table.Attach(deleteEntity); table.Remove(deleteEntity); context.SaveChanges(); } }
/// <summary> /// Updating entity /// </summary> /// <param name="updateEntity">Instance of the entity</param> public void Update(T updateEntity) { // _dbSet.Attach(updateEntity); //_objContext.Entry(updateEntity).State = EntityState.Modified; using (TLFCSEntities context = BaseContext.GetDbContext()) { DbSet <T> table = context.Set <T>(); table.Attach(updateEntity); context.Entry(updateEntity).State = EntityState.Modified; context.SaveChanges(); } }
/// <summary> /// Default constructor /// </summary> public TicketController() { this._dbContext = BaseContext.GetDbContext(); this._objLog = new GenericRepository <CS_Log>(); this._objStatus = new GenericRepository <CS_Status>(); this._objProjectTeam = new GenericRepository <ProjectTeam>(); this._objProject = new GenericRepository <Projects>(); this._objCustomer = new GenericRepository <Customer>(); this._objTicket = new GenericRepository <CS_Ticket>(); this._objSLA = new GenericRepository <CS_SLA>(); this._objCallLog = new GenericRepository <CS_CallLog>(); this._objPriority = new GenericRepository <CS_Priority>(); this._objEmployee = new GenericRepository <Employee>(); this._objLink = new GenericRepository <CS_EmailLink>(); }
public ActionResult Login(string name, string password, string rememberme) { if (rememberme == "on") { Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(30); Response.Cookies["Password"].Expires = DateTime.Now.AddDays(30); } else { Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1); Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1); } Response.Cookies["UserName"].Value = name.Trim(); Response.Cookies["Password"].Value = password.Trim(); // Encrypt password password = Utility.Encrypt(password); // Database context TLFCSEntities dbcontext = new TLFCSEntities(); //Fetch username and password var user = (from u in dbcontext.Users where u.Name.Equals(name) && u.Password.Equals(password) select u); foreach (var item in user) { // Fetch EmployeeId from employee based on userid var emp = (from v in dbcontext.Employee where v.User_Id == item.Id select v); foreach (var item1 in emp) { Session["user"] = Convert.ToString(item1.Id); Session["userName"] = item.Name; Session["userId"] = Convert.ToString(item1.Id); int[] roleId = (from w in dbcontext.UserRole where w.Users_Id == item1.User_Id select w.Roles_Id).ToArray(); Session["userRole"] = roleId; return(RedirectToAction(ActionName.TicketIndex, ControllerName.Ticket)); } } return(RedirectToAction(ActionName.AuthenticationLogin, ControllerName.Authentication, "1")); }
/// <summary> /// Default Contructor /// </summary> public CommonController() { _dbContext = BaseContext.GetDbContext(); }
/// <summary> /// Create an instance of DBCustomerSupportEntities /// </summary> /// <returns>An instance of DBCustomerSupportEntities</returns> public static TLFCSEntities GetDbContext() { var context = new TLFCSEntities(); return(context); }
/// <summary> /// Default constructor /// </summary> public ProjectsCRsController() { this._dbContext = BaseContext.GetDbContext(); this._objProjectCRs = new GenericRepository <ProjectCR>(); this._objProject = new GenericRepository <Projects>(); }
/// <summary> /// Default constructor /// </summary> public ProjectsJiraController() { this._dbContext = BaseContext.GetDbContext(); this._objProjectJira = new GenericRepository <TlfmsJiraLink>(); this._objProject = new GenericRepository <Projects>(); }
/// <summary> /// Default constructor /// </summary> public ProjectsActivityController() { this._dbContext = BaseContext.GetDbContext(); this._objProjectActivity = new GenericRepository <ProjectActivityLink>(); this._objProject = new GenericRepository <Projects>(); }
/// <summary> /// Default constructor /// </summary> public ProjectsTeamController() { this._dbContext = BaseContext.GetDbContext(); this._objProjectTeam = new GenericRepository <ProjectTeam>(); this._objProject = new GenericRepository <Projects>(); }
/// <summary> /// Default constructor /// </summary> public ProjectsDeadlineController() { this._dbContext = BaseContext.GetDbContext(); this._objProjectDeadline = new GenericRepository <ProjectDeadline>(); this._objProject = new GenericRepository <Projects>(); }
/// <summary> /// Default constructor /// </summary> public CustomersController() { this._dbContext = BaseContext.GetDbContext(); this._objCustomer = new GenericRepository <Customer>(); }
/// <summary> /// Default constructor /// </summary> public ProjectsRDemandController() { this._dbContext = BaseContext.GetDbContext(); this._objProjectDemand = new GenericRepository <ProjectResourceDemand>(); this._objProject = new GenericRepository <Projects>(); }