/// <summary> ///This method is used to get branch detail of the specific Id -JJ /// </summary> /// <param name="id">Id of branch</param> /// <returns>return BranchDetailAC object</returns> public BranchDetailAC GetBranchById(int id) { try { var branchDetail = _branchContext.GetById(id); BranchDetailAC branches = new BranchDetailAC() { Id = id, Name = branchDetail.Name, NameSl = branchDetail.NameSl, Code = branchDetail.Code, Storename = branchDetail.Storename, Email = branchDetail.Email, Fax = branchDetail.Fax, Address = branchDetail.Address, IsAutomaticIssueSPO = branchDetail.IsAutomaticIssueSPO, Phone = branchDetail.Phone, CompanyId = branchDetail.CompanyId, Zipcode = branchDetail.Zipcode }; return(branches); } catch (Exception ex) { _errorLog.LogException(ex); throw; } }
public BranchDetailAC GetBranchById(int Id) { var branchDetail = _branchDetail.GetById(Id); if (branchDetail != null) { var branches = new BranchDetailAC() { Id = Id, Name = branchDetail.Name, NameSl = branchDetail.NameSl, Code = branchDetail.Code, Storename = branchDetail.Storename, Email = branchDetail.Email, Fax = branchDetail.Fax, Address = branchDetail.Address, IsAutomaticIssueSPO = branchDetail.IsAutomaticIssueSPO, Phone = branchDetail.Phone, CompanyId = branchDetail.CompanyId, Zipcode = branchDetail.Zipcode, CreatedDateTime = branchDetail.CreatedDateTime, }; return(branches); } return(null); }
/// <summary> /// This method is used to add branch to the system - JJ /// </summary> /// <param name="branchDetail">object of BranchDetailAC</param> /// <param name="userName"></param> /// <returns>return BranchDetailAC object</returns> public BranchDetailAC AddBranchDetail(BranchDetailAC branchDetail, string userName) { try { var currentUser = _userDataRepository.First(x => x.UserName == userName && x.IsDelete == false); int companyId = 0; if (_companyDetailContext.Fetch(x => x.UserId == currentUser.UserId).ToList().Any()) { companyId = _companyDetailContext.First(x => x.UserId == currentUser.UserId).Id; } if (CheckBranchNameIdExist(branchDetail.Name, branchDetail.Id, companyId)) { branchDetail.Name = "invalid"; return(branchDetail); } else if (CheckCodeIdExist(branchDetail.Code, branchDetail.Id, branchDetail.CompanyId)) { branchDetail.Code = "invalid"; return(branchDetail); } else if (CheckEmailIdExist(branchDetail.Email, branchDetail.Id)) { branchDetail.Email = "invalid"; return(branchDetail); } else if (CheckPhoneIdExist(branchDetail.Phone, branchDetail.Id)) { branchDetail.Phone = "invalid"; return(branchDetail); } BranchDetail branch = new BranchDetail() { Name = branchDetail.Name, NameSl = branchDetail.NameSl, Code = branchDetail.Code, Storename = branchDetail.Storename, Email = branchDetail.Email, Fax = branchDetail.Fax, Address = branchDetail.Address, IsAutomaticIssueSPO = branchDetail.IsAutomaticIssueSPO, Phone = branchDetail.Phone, CompanyId = companyId, Zipcode = branchDetail.Zipcode, CreatedDateTime = DateTime.UtcNow }; _branchContext.Add(branch); _branchContext.SaveChanges(); branchDetail.CompanyId = companyId; branchDetail.Id = branch.Id; return(branchDetail); } catch (Exception ex) { _errorLog.LogException(ex); throw; } }
/// <summary> /// This method is used to update branch - JJ /// </summary> /// <param name="branchDetail">object of BranchDetailAC</param> /// <returns>null</returns> public void UpdateBranchDetail(BranchDetailAC branchDetail) { var updateBranch = _branchContext.GetById(branchDetail.Id); updateBranch.IsAutomaticIssueSPO = branchDetail.IsAutomaticIssueSPO; updateBranch.IsDelete = branchDetail.IsDelete; updateBranch.Name = branchDetail.Name; updateBranch.NameSl = branchDetail.NameSl; updateBranch.Phone = branchDetail.Phone; updateBranch.Storename = branchDetail.Storename; updateBranch.Zipcode = branchDetail.Zipcode; updateBranch.Address = branchDetail.Address; updateBranch.Code = branchDetail.Code; updateBranch.Email = branchDetail.Email; updateBranch.Fax = branchDetail.Fax; updateBranch.ModifiedDateTime = DateTime.UtcNow; _branchContext.Update(updateBranch); _branchContext.SaveChanges(); }
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; } }
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; } }