Example #1
0
        public ActionResult NewTicket([Bind(Include = "UserID,CategoryID,PriorityID,StatusID,DateCreated,Deadline,Subject,Active,LastModified,AssigneeID,ProductID,Body,OrganizationID")] BusinessObjects.Ticket ticket)
        {
            var response = ticketmanager.Save(ticket);

            if (!response.IsError)
            {
                return(RedirectToAction("/TicketList"));
            }

            else
            {
                ViewBag.AssigneeID     = new SelectList(usermanager.DropDownUser(), "ID", "Email");
                ViewBag.ProductID      = new SelectList(productmanager.DropDownProduct(), "ID", "Name_Prod");
                ViewBag.OrganizationID = new SelectList(OrganizationService.DropDownOrganisation(), "ID", "Name");
                ViewBag.CategoryID     = new SelectList(categorymanager.DropDownCategory(), "ID", "Name");
                ViewBag.PriorityID     = new SelectList(prioritymanager.DropDownPriority(), "ID", "Name");
                ViewBag.StatusID       = new SelectList(statusmanager.DropDownStatus(), "ID", "Name");

                foreach (var failer in response.ValidationResult.Errors)
                {
                    ModelState.AddModelError(failer.PropertyName, failer.ErrorMessage);
                }
                return(View());
            }
        }
        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 List <BusinessObjects.Ticket> GetFilteredTicketList(BusinessObjects.Ticket filter)
        {
            Logger.TraceMethodStart(ClassName, "GetFilteredTicketList");

            var ticket = default(List <BusinessObjects.Ticket>);


            try
            {
                using (var db = new DAL.EntityModel.BugTrackingEntities())
                {
                    var query = db.Tickets.Where(c => c.Active == true);
                    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, "GetFilteredTicketList");
            }
        }
Example #4
0
        public ActionResult TicketList([Bind(Include = "ID,UserID,CategoryID,PriorityID,StatusID,DateCreated,Deadline,Subject,Active,LastModified,AssigneeID,ProductID,Body,OrganizationID")] BusinessObjects.Ticket search)
        {
            ViewData["ProductID"]      = new SelectList(productmanager.DropDownProduct(), "ID", "Name_Prod");
            ViewData["OrganizationID"] = new SelectList(OrganizationService.DropDownOrganisation(), "ID", "Name");
            ViewData["CategoryID"]     = new SelectList(categorymanager.DropDownCategory(), "ID", "Name");
            ViewData["PriorityID"]     = new SelectList(prioritymanager.DropDownPriority(), "ID", "Name");
            ViewData["StatusID"]       = new SelectList(statusmanager.DropDownStatus(), "ID", "Name");
            var ticketList = ticketmanager.GetFilteredTicketList(search);

            return(View(ticketList));
        }
        public BugTrackingResponse <BusinessObjects.Ticket> SaveEdit(BusinessObjects.Ticket ticket)
        {
            Logger.TraceMethodStart(ClassName, "SaveEdit");

            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.LastModified = DateTime.Now;
                            var newticket = MapperAllLevels.Map <BusinessObjects.Ticket, DAL.EntityModel.Ticket>(ticket);
                            db.Entry(newticket).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");
                    }
                }
            }
        }