コード例 #1
0
 public IHttpActionResult AddBranchDetail(BranchDetailAC branchDetail)
 {
     try
     {
         var userName = HttpContext.Current.User.Identity.Name;
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             branchDetail.CompanyId = companyId;
             var branchDetails = _branchContext.AddBranchDetail(branchDetail, userName);
             if (branchDetails.Id != 0)
             {
                 _branchContext.UpdateItemQuantity(branchDetails.Id, branchDetails.CompanyId);
                 List <Ledgers> listOfLedeger = new List <Ledgers>();
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 16, LedgerName = "Cash", Name = StringConstants.CashInHand, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetails.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 3, LedgerName = "Bank", Name = StringConstants.Bank, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetails.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 17, LedgerName = "Sales", Name = StringConstants.Sales, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetails.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 17, LedgerName = "Purchase", Name = StringConstants.Purchase, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetails.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 14, LedgerName = StringConstants.Loss, Name = StringConstants.Loss, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetails.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 8, LedgerName = StringConstants.Expenses, Name = StringConstants.Expenses, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetails.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 6, LedgerName = "Credit Note", Name = StringConstants.CRNote, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetails.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 17, LedgerName = StringConstants.StockInHand, Name = StringConstants.StockInHand, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetails.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 12, LedgerName = StringConstants.Income, Name = StringConstants.Income, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetails.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 17, LedgerName = StringConstants.SalesReturn, Name = StringConstants.SalesReturn, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetails.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 17, LedgerName = StringConstants.PurchaseRetrun, Name = StringConstants.PurchaseRetrun, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetails.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0
                 });
                 _iLedgerAccountRepository.AddLedgersForBranch(listOfLedeger);
             }
             return(Ok(branchDetails));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }