public IHttpActionResult UpdateBranchDetail(BranchDetailAC branchDetail)
 {
     try
     {
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             if (_branchContext.CheckBranchNameIdExist(branchDetail.Name, branchDetail.Id, branchDetail.CompanyId))
             {
                 var nameExists = true;
                 return(Ok(new { nameExists }));
             }
             else if (_branchContext.CheckCodeIdExist(branchDetail.Code, branchDetail.Id, branchDetail.CompanyId))
             {
                 var codeExists = true;
                 return(Ok(new { codeExists }));
             }
             else if (_branchContext.CheckEmailIdExist(branchDetail.Email, branchDetail.Id))
             {
                 var emailExixts = true;
                 return(Ok(new { emailExixts }));
             }
             else if (_branchContext.CheckPhoneIdExist(branchDetail.Phone, branchDetail.Id))
             {
                 var phoneExists = true;
                 return(Ok(new { phoneExists }));
             }
             else
             {
                 _branchContext.UpdateBranchDetail(branchDetail);
                 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 = branchDetail.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0, CompanyId = companyId
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 3, LedgerName = "Bank", Name = StringConstants.Bank, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetail.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0, CompanyId = companyId
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 17, LedgerName = "Sales", Name = StringConstants.Sales, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetail.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0, CompanyId = companyId
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 17, LedgerName = "Purchase", Name = StringConstants.Purchase, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetail.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0, CompanyId = companyId
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 14, LedgerName = StringConstants.Loss, Name = StringConstants.Loss, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetail.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0, CompanyId = companyId
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 8, LedgerName = StringConstants.Expenses, Name = StringConstants.Expenses, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetail.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0, CompanyId = companyId
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 6, LedgerName = "Credit Note", Name = StringConstants.CRNote, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetail.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0, CompanyId = companyId
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 17, LedgerName = StringConstants.StockInHand, Name = StringConstants.StockInHand, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetail.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0, CompanyId = companyId
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 12, LedgerName = StringConstants.Income, Name = StringConstants.Income, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetail.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0, CompanyId = companyId
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 17, LedgerName = StringConstants.SalesReturn, Name = StringConstants.SalesReturn, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetail.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0, CompanyId = companyId
                 });
                 listOfLedeger.Add(new Ledgers {
                     GroupId = 17, LedgerName = StringConstants.PurchaseRetrun, Name = StringConstants.PurchaseRetrun, Address = "Baroda", CreatedDateTime = DateTime.UtcNow, IsEditable = false, State = "Gujrat", BranchId = branchDetail.Id, SuplierId = null, Comment = null, ParentLedgerId = null, Balance = 0, CompanyId = companyId
                 });
                 _iLedgerAccountRepository.AddLedgersForBranch(listOfLedeger);
                 return(Ok(branchDetail));
             }
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }