Esempio n. 1
0
        public int AddIncident(POSTIncidentDomain incident, int userTenantId)
        {
            if (incident == null)
            {
                throw new NsiArgumentException(ExceptionMessages.ArgumentException);
            }

            if (!incident.TenantId.Equals(userTenantId))
            {
                throw new NsiArgumentException(IncidentMessages.TenantInvalidId);
            }

            //Logic for already solved incidents
            //Fetch incident settlement data which has same type
            //as given incident
            IncidentSettlementDomain incidentSettlement = _incidentWorkOrderRepository.GetIncidentSettlementByTypeId(incident.IncidentType);

            if (incidentSettlement != null)
            {
                //map given incident settlement to current incident
                IncidentSettlementDomain automatedIncidentSettlement = mapIncidentSettlement(incidentSettlement, incident.TenantId);
                //save created settlement
                _incidentSettlementRepository.AddIncidentSettlement(automatedIncidentSettlement);
                //send notification
                sendNotification(automatedIncidentSettlement.Description,
                                 automatedIncidentSettlement.TenantId);
            }
            return(_incidentRepository.AddIncident(incident, userTenantId));
        }
Esempio n. 2
0
        public void UpdateIncident(POSTIncidentDomain incident, int userTenantId)
        {
            if (incident == null)
            {
                throw new NsiArgumentException(ExceptionMessages.ArgumentException);
            }

            if (!incident.TenantId.Equals(userTenantId))
            {
                throw new NsiArgumentException(IncidentMessages.TenantInvalidId);
            }

            _incidentRepository.UpdateIncident(incident, userTenantId);
        }
Esempio n. 3
0
        public int AddIncident(POSTIncidentDomain incident, int userTenantId)
        {
            if (incident == null)
            {
                throw new NsiArgumentException(ExceptionMessages.ArgumentException);
            }

            if (incident.TenantId != userTenantId)
            {
                throw new NsiArgumentException(IncidentMessages.TenantInvalidId);
            }

            if (!_context.Device.Any(x => x.DeviceId == incident.DeviceId))
            {
                throw new NsiArgumentException(DeviceMessages.DeviceInvalidId);
            }

            if (!_context.Tenant.Any(x => x.TenantId == incident.TenantId))
            {
                throw new NsiArgumentException(IncidentMessages.TenantInvalidId);
            }

            if (!_context.Priority.Any(x => x.PriorityId == incident.Priority))
            {
                throw new NsiArgumentException(IncidentMessages.IncidentPriorityInvalidId);
            }

            if (!_context.IncidentStatus.Any(x => x.IncidentStatusId == incident.IncidentStatus))
            {
                throw new NsiArgumentException(IncidentMessages.IncidentStatusInvalidId);
            }

            if (!_context.IncidentType.Any(x => x.IncidentTypeId == incident.IncidentType))
            {
                throw new NsiArgumentException(IncidentMessages.IncidentTypeInvalidId);
            }

            var incidentDb = new Incident().FromDomainModel(incident);

            _context.Incident.Add(incidentDb);
            _context.SaveChanges();
            return(incidentDb.IncidentId);
        }
Esempio n. 4
0
        public void UpdateIncident(POSTIncidentDomain incident, int userTenantId)
        {
            if (incident == null)
            {
                throw new NsiArgumentException(IncidentMessages.IncidentNotFound);
            }

            if (!_context.Device.Any(x => x.DeviceId == incident.DeviceId))
            {
                throw new NsiArgumentException(DeviceMessages.DeviceInvalidId);
            }

            if (!_context.Tenant.Any(x => x.TenantId == incident.TenantId))
            {
                throw new NsiArgumentException(IncidentMessages.TenantInvalidId);
            }

            if (!_context.Priority.Any(x => x.PriorityId == incident.Priority))
            {
                throw new NsiArgumentException(IncidentMessages.IncidentPriorityInvalidId);
            }

            if (!_context.IncidentStatus.Any(x => x.IncidentStatusId == incident.IncidentStatus))
            {
                throw new NsiArgumentException(IncidentMessages.IncidentStatusInvalidId);
            }

            if (!_context.IncidentType.Any(x => x.IncidentTypeId == incident.IncidentType))
            {
                throw new NsiArgumentException(IncidentMessages.IncidentTypeInvalidId);
            }

            if (userTenantId != incident.TenantId)
            {
                throw new NsiArgumentException(IncidentMessages.TenantInvalidId);
            }

            var incidentDb = _context.Incident.FirstOrDefault(x => x.IncidentId == incident.IncidentId);

            incidentDb.FromDomainModel(incident);
            _context.SaveChanges();
        }
Esempio n. 5
0
        public static Incident FromDomainModel(this Incident obj, POSTIncidentDomain domain)
        {
            if (obj == null)
            {
                obj = new Incident();
            }

            obj.IncidentId       = domain.IncidentId;
            obj.DateCreated      = domain.DateCreated;
            obj.CreatedBy        = domain.CreatedBy;
            obj.ModifiedBy       = domain.ModifiedBy;
            obj.DateModified     = domain.DateModified;
            obj.TenantId         = domain.TenantId;
            obj.IncidentStatusId = domain.IncidentStatus;
            obj.DeviceId         = domain.DeviceId;
            obj.PriorityId       = domain.Priority;
            obj.IncidentTypeId   = domain.IncidentType;
            obj.ReporterId       = domain.ReporterId;
            obj.AssigneeId       = domain.AssigneeId;

            return(obj);
        }
Esempio n. 6
0
        public void EditIncident([FromBody] POSTIncidentDomain incident)
        {
            int userTenantId = (int)ActionContext.Request.Properties["UserTenantId"];

            _incidentManipulation.UpdateIncident(incident, userTenantId);
        }
Esempio n. 7
0
        public int AddIncident([FromBody] POSTIncidentDomain incident)
        {
            int userTenantId = (int)ActionContext.Request.Properties["UserTenantId"];

            return(_incidentManipulation.AddIncident(incident, userTenantId));
        }