public List <BusinessObjects.Category> DropDownCategory() { Logger.TraceMethodStart(ClassName); var dropdown = default(List <BusinessObjects.Category>); try { using (var db = new EntityModel.BugTrackingEntities()) { var Categoryquery = db.Categories.Select(c => c).Where(d => d.Active).ToList(); dropdown = MapperAllLevels.Map <List <EntityModel.Category>, List <BusinessObjects.Category> >(Categoryquery); return(dropdown); } } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "DropDownCategory"); } }
public List <BusinessObjects.Organization> DropDownOrganisation() { Logger.TraceMethodStart(ClassName, "DropDownOrganisation"); var dropdown = default(List <BusinessObjects.Organization>); try { using (var db = new EntityModel.BugTrackingEntities()) { var Organisationquery = db.Organizations.Where(c => c.Active).ToList(); dropdown = MapperAllLevels.Map <List <EntityModel.Organization>, List <BusinessObjects.Organization> >(Organisationquery); return(dropdown); } } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "DropDownOrganisation"); } }
public List <BusinessObjects.Status> GetStatus() { Logger.TraceMethodStart(ClassName, "GetStatus"); var status = default(List <BusinessObjects.Status>); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.Status.Where(c => c.Active).ToList(); status = MapperAllLevels.Map <List <EntityModel.Status>, List <BusinessObjects.Status> >(query); return(status); } } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "GetStatus"); } }
public List <BusinessObjects.AspNetUser> SelectAll() { Logger.TraceMethodStart(ClassName); var boList = default(List <BusinessObjects.AspNetUser>); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.AspNetUsers.Where(x => x.Active == true).ToList(); boList = MapperAllLevels.Map <List <EntityModel.AspNetUser>, List <BusinessObjects.AspNetUser> >(query); return(boList); } } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName); } }
public List <BusinessObjects.Product> GetProduct() { Logger.TraceMethodStart(ClassName, "GetProduct"); var prod = default(List <BusinessObjects.Product>); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.Products.Where(c => c.Active == true).ToList(); //Logger.ServiceDebug($"FILTER: [{JsonExtensions.ToJson(query)}].", ClassName); prod = MapperAllLevels.Map <List <EntityModel.Product>, List <BusinessObjects.Product> >(query); return(prod); } } catch (Exception ex) { Logger.TraceError("Exception:", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "GetProduct"); } }
public void SaveUserRole(BusinessObjects.AspNetUserRole UserRole) { Logger.TraceMethodStart(ClassName, "Save"); using (var db = new EntityModel.BugTrackingEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { UserRole.LastModified = DateTime.Now; UserRole.Active = true; var newUserRole = MapperAllLevels.Map <BusinessObjects.AspNetUserRole, EntityModel.AspNetUserRole>(UserRole); db.AspNetUserRoles.Add(newUserRole); db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { Logger.TraceError("Exception: ", ex); transaction.Rollback(); } finally { Logger.TraceMethodEnd(ClassName, "Save"); } } } }
public void SaveEditUser(BusinessObjects.User User) { Logger.TraceMethodStart(ClassName, "SaveEditUser"); using (var db = new EntityModel.BugTrackingEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { User.LastModified = DateTime.Now; var resp = MapperAllLevels.Map <BusinessObjects.User, EntityModel.User>(User); db.Entry(resp).State = EntityState.Modified; db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { Logger.TraceError("Exception: ", ex); transaction.Rollback(); } finally { Logger.TraceMethodEnd(ClassName, "SaveEditUser"); } } } }
public List <BusinessObjects.User> GetInactiveUserList() { Logger.TraceMethodStart(ClassName, "GetInactiveUserList"); var users = default(List <BusinessObjects.User>); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.Users.Where(c => c.Active == false) .ToList(); users = MapperAllLevels.Map <List <EntityModel.User>, List <BusinessObjects.User> >(query); return(users); } } catch (Exception ex) { Logger.TraceError("Exception:", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "GetInactiveUserList"); } }
public BusinessObjects.Status EditStatus(int Id) { Logger.TraceMethodStart(ClassName, "EditStatus"); var status = default(BusinessObjects.Status); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.Status.Where(c => c.ID == Id && c.Active).FirstOrDefault(); status = MapperAllLevels.Map <EntityModel.Status, BusinessObjects.Status>(query); return(status); } } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "EditStatus"); } }
public BusinessObjects.ProductOrganisation DeleteOrganization(int Id) { Logger.TraceMethodStart(ClassName, "DeleteOrganization"); var org = default(BusinessObjects.ProductOrganisation); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.ProductOrganisations.Where(c => c.ID == Id && c.Active == true).FirstOrDefault(); org = MapperAllLevels.Map <EntityModel.ProductOrganisation, BusinessObjects.ProductOrganisation>(query); return(org); } } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "DeleteOrganization"); } }
public BusinessObjects.Product EditProduct(long Id) { Logger.TraceMethodStart(ClassName, "EditProduct"); var prod = default(BusinessObjects.Product); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.Products.Where(c => c.ID == Id && c.Active == true).FirstOrDefault(); prod = MapperAllLevels.Map <EntityModel.Product, BusinessObjects.Product>(query); return(prod); } } catch (Exception ex) { Logger.TraceError("Exception ex", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "EditProduct"); } }
public List <BusinessObjects.Product> DropDownProduct() { Logger.TraceMethodStart(ClassName); var dropdown = default(List <BusinessObjects.Product>); try { using (var db = new EntityModel.BugTrackingEntities()) { var Productquery = db.Products.Where(c => c.Active == true).ToList(); dropdown = MapperAllLevels.Map <List <EntityModel.Product>, List <BusinessObjects.Product> >(Productquery); return(dropdown); } } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "DropDownProduct"); } }
public BusinessObjects.Ticket DeleteTicket(long Id) { Logger.TraceMethodStart(ClassName, "DeleteTicket"); var ticket = default(BusinessObjects.Ticket); try { using (var db = new DAL.EntityModel.BugTrackingEntities()) { var query = db.Tickets.Where(c => c.ID == Id && c.Active == true).FirstOrDefault(); ticket = MapperAllLevels.Map <DAL.EntityModel.Ticket, BusinessObjects.Ticket>(query); return(ticket); } } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "DeleteProduct"); } }
public List <BusinessObjects.Ticket> GetTicketList() { Logger.TraceMethodStart(ClassName, "GetTicketList"); var ticket = default(List <BusinessObjects.Ticket>); try { using (var db = new DAL.EntityModel.BugTrackingEntities()) { var query = db.Tickets.Where(c => c.Active == true) .Include(x => x.Status) .Include(x => x.Priority) .Include(x => x.Category) .Include(x => x.User) .Include(x => x.Product) .Include(x => x.Organization).ToList(); ; ticket = MapperAllLevels.Map <List <DAL.EntityModel.Ticket>, List <BusinessObjects.Ticket> >(query); return(ticket); } } catch (Exception ex) { Logger.TraceError("Exception:", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "GetTicketList"); } }
public BusinessObjects.User DeleteUser(int Id) { Logger.TraceMethodStart(ClassName, "DeleteUser"); var user = default(BusinessObjects.User); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.Users.Where(c => c.ID == Id && c.Active == true).FirstOrDefault(); user = MapperAllLevels.Map <EntityModel.User, BusinessObjects.User>(query); return(user); } } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "DeleteUser"); } }
public BusinessObjects.Priority EditPriority(int Id) { Logger.TraceMethodStart(ClassName, "EditPriority"); var prior = default(BusinessObjects.Priority); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.Priorities.Where(c => c.ID == Id && c.Active).FirstOrDefault(); prior = MapperAllLevels.Map <EntityModel.Priority, BusinessObjects.Priority>(query); return(prior); } } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "EditPriority"); } }
public BusinessObjects.Responsible DeleteResponsible(int Id) { Logger.TraceMethodStart(ClassName, "DeleteResponsible"); var resp = default(BusinessObjects.Responsible); try { using (var db = new EntityModel.BugTrackingEntities()) { using (var transaction = db.Database.BeginTransaction()) { var query = db.Responsibles.Where(c => c.ID == Id && c.Active == true).FirstOrDefault(); resp = MapperAllLevels.Map <EntityModel.Responsible, BusinessObjects.Responsible>(query); return(resp); } } } catch (Exception ex) { Logger.TraceError("Exception:", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "DeleteResponsible"); } }
public List <BusinessObjects.ProductOrganisation> GetProductOrganizationList() { Logger.TraceMethodStart(ClassName, "GetProductOrganizationList"); var prod = default(List <BusinessObjects.ProductOrganisation>); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.ProductOrganisations.Where(c => c.Active == true) .Include(x => x.Product) .Include(x => x.Organization).ToList(); ; prod = MapperAllLevels.Map <List <EntityModel.ProductOrganisation>, List <BusinessObjects.ProductOrganisation> >(query); return(prod); } } catch (Exception ex) { Logger.TraceError("Exception:", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "GetProductOrganizationList"); } }
public BusinessObjects.AspNetRole EditRole(string Id) { Logger.TraceMethodStart(ClassName, "EditRole"); var role = default(BusinessObjects.AspNetRole); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.AspNetRoles.Where(c => c.Id == Id && c.Active == true).FirstOrDefault(); role = MapperAllLevels.Map <DAL.EntityModel.AspNetRole, BusinessObjects.AspNetRole>(query); return(role); } } catch (Exception ex) { Logger.TraceError("Exception ex", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "EditRole"); } }
public List <BusinessObjects.Ticket> GetFilteredTechnicianTicketList(BusinessObjects.Ticket filter) { Logger.TraceMethodStart(ClassName, "GetFilteredTechnicianTicketList"); var ticket = default(List <BusinessObjects.Ticket>); try { using (var db = new DAL.EntityModel.BugTrackingEntities()) { var UserID = System.Web.HttpContext.Current.User.Identity.GetUserId(); var Assigned = db.Users.Where(c => c.UserId == UserID).Select(c => c.ID).First(); var query = db.Tickets.Where(c => c.Active == true && c.AssigneeID == Assigned); if (filter.ProductID.ToString() != "0") { query = query.Where(c => c.ProductID == filter.ProductID); } if (filter.CategoryID.ToString() != "0") { query = query.Where(c => c.CategoryID == filter.CategoryID); } if (filter.StatusID.ToString() != "0") { query = query.Where(c => c.StatusID == filter.StatusID); } if (filter.OrganizationID.ToString() != "0") { query = query.Where(c => c.OrganizationID == filter.OrganizationID); } if (filter.PriorityID.ToString() != "0") { query = query.Where(c => c.PriorityID == filter.PriorityID); } query = query.Include(x => x.Status) .Include(x => x.Priority) .Include(x => x.Category) .Include(x => x.User) .Include(x => x.Product) .Include(x => x.Organization); ; ; ticket = MapperAllLevels.Map <List <DAL.EntityModel.Ticket>, List <BusinessObjects.Ticket> >(query.ToList()); return(ticket); } } catch (Exception ex) { Logger.TraceError("Exception:", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "GetFilteredTechnicianTicketList"); } }
public BugTrackingResponse <Ticket> Save(Ticket ticket) { Logger.TraceMethodStart(ClassName, "SaveTicket"); var response = new BugTrackingResponse <BusinessObjects.Ticket>(); using (var db = new DAL.EntityModel.BugTrackingEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { var UserID = System.Web.HttpContext.Current.User.Identity.GetUserId(); ticket.UserID = UserID; var validator = new TicketSaveSpecificaion(); var result = validator.Validate(ticket); var failures = result.Errors; response.ValidationResult = result; if (result.IsValid) { ticket.Active = true; ticket.DateCreated = DateTime.Now; ticket.LastModified = DateTime.Now; var _ticket = MapperAllLevels.Map <BusinessObjects.Ticket, DAL.EntityModel.Ticket>(ticket); db.Tickets.Add(_ticket); db.SaveChanges(); transaction.Commit(); } else { transaction.Rollback(); Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors); } return(response); } catch (Exception ex) { Logger.TraceError("Exception: ", ex); transaction.Rollback(); throw; } finally { Logger.TraceMethodEnd(ClassName, "SaveTicket"); } } } }
public BugTrackingResponse <BusinessObjects.ProductOrganisation> DeleteOrganizationConfirmed(int Id) { Logger.TraceMethodStart(ClassName, "DeleteOrganizationConfirmed"); var response = new BugTrackingResponse <BusinessObjects.ProductOrganisation>(); using (var db = new EntityModel.BugTrackingEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { var query = db.ProductOrganisations.Where(c => c.ID == Id && c.Active == true).FirstOrDefault(); var prodorg = MapperAllLevels.Map <EntityModel.ProductOrganisation, BusinessObjects.ProductOrganisation>(query); var validator = new ProdOrganizationDeleteSpecification(); var result = validator.Validate(prodorg); var failures = result.Errors; response.ValidationResult = result; if (result.IsValid) { //db.ProductOrganisations.Remove(query); query.Active = false; query.LastModified = DateTime.Now; db.SaveChanges(); transaction.Commit(); } else { transaction.Rollback(); Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors); } return(response); } catch (Exception ex) { Logger.TraceError("Exception: ", ex); transaction.Rollback(); throw; } finally { Logger.TraceMethodEnd(ClassName, "DeleteOrganizationConfirmed"); } } } }
public BugTrackingResponse <BusinessObjects.AspNetRole> Save(BusinessObjects.AspNetRole role) { Logger.TraceMethodStart(ClassName, "Save"); var response = new BugTrackingResponse <BusinessObjects.AspNetRole>(); using (var db = new EntityModel.BugTrackingEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { var validator = new RoleSpecification(); var result = validator.Validate(role); var failures = result.Errors; response.ValidationResult = result; if (result.IsValid) { role.Id = Guid.NewGuid().ToString(); role.LastModified = DateTime.Now; role.Active = true; var newrole = MapperAllLevels.Map <BusinessObjects.AspNetRole, EntityModel.AspNetRole>(role); db.AspNetRoles.Add(newrole); db.SaveChanges(); transaction.Commit(); } else { transaction.Rollback(); Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors); } return(response); } catch (Exception ex) { Logger.TraceError("Exception: ", ex); transaction.Rollback(); throw; } finally { Logger.TraceMethodEnd(ClassName, "Save"); } } } }
public BugTrackingResponse <BusinessObjects.ProductOrganisation> SaveProductOrganisation(BusinessObjects.ProductOrganisation productorganisation) { Logger.TraceMethodStart(ClassName, "SaveProductOrganisation"); var response = new BugTrackingResponse <BusinessObjects.ProductOrganisation>(); using (var db = new EntityModel.BugTrackingEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { var validator = new ProdOrganizationSpecification(); var result = validator.Validate(productorganisation); var failures = result.Errors; response.ValidationResult = result; if (result.IsValid) { productorganisation.Active = true; productorganisation.LastModified = DateTime.Now; var productorg = MapperAllLevels.Map <BusinessObjects.ProductOrganisation, EntityModel.ProductOrganisation>(productorganisation); db.ProductOrganisations.Add(productorg); db.SaveChanges(); transaction.Commit(); } else { transaction.Rollback(); Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors); } return(response); } catch (Exception ex) { Logger.TraceError("Exception: ", ex); transaction.Rollback(); throw; } finally { Logger.TraceMethodEnd(ClassName, "SaveProductOrganisation"); } } } }
public BugTrackingResponse <BusinessObjects.Category> SaveEdit(BusinessObjects.Category category) { Logger.TraceMethodStart(ClassName, "SaveEdit"); var response = new BugTrackingResponse <BusinessObjects.Category>(); using (var db = new EntityModel.BugTrackingEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { var validator = new CategoryUpdateSpecification(); var result = validator.Validate(category); var failures = result.Errors; response.ValidationResult = result; if (result.IsValid) { category.LastModified = DateTime.Now; var newcat = MapperAllLevels.Map <BusinessObjects.Category, EntityModel.Category>(category); db.Entry(newcat).State = EntityState.Modified; db.SaveChanges(); transaction.Commit(); } else { transaction.Rollback(); Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors); } return(response); } catch (Exception ex) { Logger.TraceError("Exception: ", ex); transaction.Rollback(); throw; } finally { Logger.TraceMethodEnd(ClassName, "SaveEdit"); } } } }
public List <BusinessObjects.AspNetUser> GetRoleList() { Logger.TraceMethodStart(ClassName, "GetRoleList"); var roles = default(List <BusinessObjects.AspNetUser>); try { using (var db = new EntityModel.BugTrackingEntities()) { var query = db.AspNetUsers.Where(c => c.Active == true) .Include(x => x.Users) .Include(x => x.AspNetUserRoles) .ToList(); /*var query=from c in db.AspNetUsers * join cr in db.Users on c.Id equals cr.UserId * join r in db.AspNetUserRoles on c.Id equals r.UserId * join k in db.AspNetRoles on r.RoleId equals k.Id * where c.Active == true * orderby c.UserName * select new { FirstName = cr.FirstName, LastName = cr.LastName, Name = k.Name, Description = k.Description }; * * var q = query.ToList();*/ roles = MapperAllLevels.Map <List <EntityModel.AspNetUser>, List <BusinessObjects.AspNetUser> >(query); string json = JsonConvert.SerializeObject(roles, Formatting.Indented, new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects }); Logger.LogDebug(json); return(roles); } } catch (Exception ex) { Logger.TraceError("Exception:", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "GetRoleList"); } }
public BusinessObjects.Category DeleteCategory(long Id) { Logger.TraceMethodStart(ClassName, "DeleteCategory"); var category = default(BusinessObjects.Category); try { var query = UoW.Categories.SelectCategory(Id); category = MapperAllLevels.Map <EntityModel.Category, BusinessObjects.Category>(query); return(category); } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "DeleteCategory"); } }
public void DeleteUserConfirmed(int Id) { Logger.TraceMethodStart(ClassName, "DeleteUserConfirmed"); using (var db = new EntityModel.BugTrackingEntities()) { using (var transaction = db.Database.BeginTransaction()) { try { var query = db.Users.Where(c => c.ID == Id && c.Active == true) .Include(x => x.AspNetUser) .FirstOrDefault(); var user = MapperAllLevels.Map <EntityModel.User, BusinessObjects.User>(query); //db.Users.Remove(query); query.Active = false; query.LastModified = DateTime.Now; query.AspNetUser.Active = false; db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { Logger.TraceError("Exception: ", ex); transaction.Rollback(); } finally { Logger.TraceMethodEnd(ClassName, "DeleteUserConfirmed"); } } } }
public BugTrackingResponse <BusinessObjects.Category> Save(BusinessObjects.Category category) { Logger.TraceMethodStart(ClassName, "Save"); var response = new BugTrackingResponse <BusinessObjects.Category>(); try { var validator = new CategorySpecification(); var result = validator.Validate(category); var failures = result.Errors; response.ValidationResult = result; if (result.IsValid) { category.LastModified = DateTime.Now; category.Active = true; var newcategory = MapperAllLevels.Map <BusinessObjects.Category, EntityModel.Category>(category); UoW.Categories.Add(newcategory); UoW.Complete(); } else { Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors); } return(response); } catch (Exception ex) { Logger.TraceError("Exception: ", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "Save"); } }
public List <BusinessObjects.Category> GetCategories() { Logger.TraceMethodStart(ClassName, "GetCategories"); var categories = default(List <BusinessObjects.Category>); try { var query = UoW.Categories.GetActiveCategories(true); categories = MapperAllLevels.Map <List <EntityModel.Category>, List <BusinessObjects.Category> >(query); return(categories); } catch (Exception ex) { Logger.TraceError("Exception", ex); throw; } finally { Logger.TraceMethodEnd(ClassName, "GetCategories"); } }