Example #1
0
        public static ReadOnlyCollection <IncidentCost> AllCosts(long incidentId, int companyId)
        {
            var costs       = ByIncidentId(incidentId, companyId).ToList();
            var actionCosts = new ReadOnlyCollection <IncidentActionCost>(new List <IncidentActionCost>());
            var action      = IncidentAction.ByIncidentId(incidentId, companyId);

            if (action.Id > 0)
            {
                actionCosts = IncidentActionCost.GetByIncidentActionId(action.Id, companyId);
                foreach (var actionCost in actionCosts)
                {
                    costs.Add(new IncidentCost
                    {
                        Id             = actionCost.Id,
                        IncidentId     = incidentId,
                        BusinessRiskId = actionCost.IncidentActionId,
                        Description    = actionCost.Description,
                        Quantity       = actionCost.Quantity,
                        CompanyId      = actionCost.CompanyId,
                        Responsible    = actionCost.Responsible,
                        Amount         = actionCost.Amount,
                        Active         = actionCost.Active,
                        Source         = "A",
                        Date           = actionCost.Date
                    });
                }
            }

            return(new ReadOnlyCollection <IncidentCost>(costs));
        }
Example #2
0
        /// <summary>Get the costs of action</summary>
        /// <param name="incidentActionId">Incident action identifier</param>
        /// <param name="companyId">Company identifier</param>
        /// <returns>A list of cost of the action</returns>
        public static string GetByIncidentAction(long incidentActionId, int companyId)
        {
            var  res   = new StringBuilder("[");
            bool first = true;
            var  costs = IncidentActionCost.GetByIncidentActionId(incidentActionId, companyId);

            foreach (IncidentActionCost cost in costs)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    res.Append(",");
                }

                res.Append(cost.Json);
            }

            res.Append("]");
            return(res.ToString());
        }