public ParentChildRelationDTO PutParentChildRelation(int id, [FromBody] ParentChildRelationDTO ticket)
        {
            var editParentChildRelation = dbm.FindParentChildRelationByID(id);

            bool changesMade = false;

            if ((editParentChildRelation.Parent == null && ticket.ParentID != -1) || (editParentChildRelation.Parent != null && (editParentChildRelation.Parent.SubprocessID != ticket.ParentID)))
            {
                editParentChildRelation.Parent = dbm.FindSubprocessByID(ticket.ParentID);
                changesMade = true;
            }
            if ((editParentChildRelation.Child == null && ticket.ChildID != -1) || (editParentChildRelation.Child != null && (editParentChildRelation.Child.SubprocessID != ticket.ChildID)))
            {
                editParentChildRelation.Child = dbm.FindSubprocessByID(ticket.ChildID);
                changesMade = true;
            }

            if (changesMade)
            {
                db.SaveChanges();
            }
            return(converter.ParentChildRelationToDTO(editParentChildRelation));
        }
Example #2
0
        public TicketDTO PutTicket(int id, [FromBody] TicketDTO ticket)
        {
            var editTicket = dbm.FindTicketByID(id);

            bool changesMade = false;

            if (ticket.Description != null && ticket.Description != "" && editTicket.Description != ticket.Description)
            {
                editTicket.Description = ticket.Description;
                changesMade            = true;
            }
            if (ticket.Note != null && ticket.Note != "" && editTicket.Note != ticket.Note)
            {
                editTicket.Note = ticket.Note;
                changesMade     = true;
            }
            if (ticket.StateID > 0 && editTicket.State.StateID != ticket.StateID)
            {
                editTicket.State = dbm.FindStateByID(ticket.StateID);
                changesMade      = true;
            }
            if (ticket.SubprocessID > 0 &&
                ((editTicket.Subprocess != null &&
                  editTicket.Subprocess.SubprocessID != ticket.SubprocessID) ||
                 editTicket.Subprocess == null))
            {
                editTicket.Subprocess = dbm.FindSubprocessByID(ticket.SubprocessID);
                changesMade           = true;
            }
            else if (ticket.SubprocessID == -1 && editTicket.Subprocess != null)
            {
                editTicket.Subprocess = null;
                changesMade           = true;
            }

            if (changesMade)
            {
                db.SaveChanges();
            }
            return(converter.TicketToDTO(editTicket));
        }
Example #3
0
 public ParentChildRelation DTOToParentChildRelation(ParentChildRelationDTO a)
 {
     return(new ParentChildRelation {
         Child = a.ChildID > 0 ? dbm.FindSubprocessByID(a.ChildID) : null, ParentChildRelationID = a.ParentChildRelationID, Parent = a.ParentID > 0 ? dbm.FindSubprocessByID(a.ParentID) : null
     });
 }
Example #4
0
 public SubprocessDTO GetSubprocess(int id)
 {
     return(converter.SubprocessToDTO(dbm.FindSubprocessByID(id)));
 }