/// <summary>
        /// Save the profitloss details.
        /// </summary>
        /// <param name="model">The ProfitLoss model</param>
        public ActionResult ProfitLossSave(MODEL.ProfitLoss model)
        {
            try
            {
                ProfitLossService profitlossService = new ProfitLossService();

                if (ModelState.IsValid)
                {
                    //Get user id
                    int?userId = Session.GetUserId();

                    //ProfitLossVO profitlossVO = new ProfitLossVO(model, userId);

                    ProfitLossVO profitlossVO = model.Transpose(userId);

                    profitlossService.SaveProfitLoss(profitlossVO);
                    return(new HttpStatusCodeResult(200));
                }
                else
                {
                    throw new ApplicationException(String.Format(Constants.CANNOT_SAVE, Constants.PROFITANDLOSS));
                }
            }
            catch (ApplicationException e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
        /// <summary>
        /// Gets the list of Costcenter based on Company Id
        /// </summary>
        /// <param name="companyId">Company Id</param>
        /// <returns>Costcenter List</returns>
        private List <MODEL.CostCentre> GetCostCenterList(int?companyId)
        {
            MODEL.ProfitLoss    profitloss        = new MODEL.ProfitLoss();
            CostCenterService   costcenterService = new CostCenterService();
            List <CostCentreVO> costcenterVOList  = costcenterService.GetCostCenterList(companyId);

            foreach (CostCentreVO costcenter in costcenterVOList)
            {
                profitloss.costcenterList.Add(new MODEL.CostCentre(costcenter));
            }

            return(profitloss.costcenterList);
        }
        /// <summary>
        /// Create new p & l for specified company
        /// </summary>
        /// <param name="companyId">The company id</param>
        /// <param name="companyName">The companay name</param>
        /// <returns>The profit loss details view</returns>
        public ActionResult ProfitLossCreate(int companyId, string companyName)
        {
            try
            {
                MODEL.ProfitLoss profitloss = new MODEL.ProfitLoss();

                profitloss.costcenterList = GetCostCenterList(companyId);
                profitloss.CompanyId      = companyId;
                profitloss.CompanyName    = companyName;
                return(PartialView("ProfitLossDetails", profitloss));
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }