/// <summary> /// /// </summary> /// <param name="_company"></param> /// <returns></returns> public Dictionary <string, string> CreateCompany(COMPANY _company) { Dictionary <string, string> _CompanyOutPut = new Dictionary <string, string>(); //var returnValue = new Data_Return(); _dbContext.COMPANies.Add(_company); if (_company.ID > 0) { _dbContext.Entry(_company).State = EntityState.Modified; } int saveStatus = _dbContext.SaveChanges(); long OutPut_ID = _company.ID; _CompanyOutPut.Add("saveStatus", saveStatus.ToString()); _CompanyOutPut.Add("OutPut", OutPut_ID.ToString()); return(_CompanyOutPut); }
public bool CreateCompanyWithBranch(CompanyEntity _CompanyEntity) { COMPANY _company = new COMPANY(); _company.ID = _CompanyEntity.ID; _company.CompanyName = _CompanyEntity.CompanyName; _company.CEOName = _CompanyEntity.CEOName; _company.WebsiteUrl = _CompanyEntity.WebsiteUrl; _company.LogoPath = _CompanyEntity.LogoPath; _company.IsActive = _CompanyEntity.IsActive; _company.CreatedDate = _CompanyEntity.CreatedDate; _company.CreatedBy = _CompanyEntity.CreatedBy; _company.CompanyType = _CompanyEntity.CompanyType; _dbContext.COMPANies.Add(_company); if (_company.ID > 0) { _dbContext.Entry(_company).State = EntityState.Modified; } // _CompanyOutPut = CreateCompany(_company); //int saveStatusCompany = Convert.ToUInt16(_CompanyOutPut["saveStatus"]); //if (saveStatusCompany > 0) //{ BRANCH _branch = new BRANCH(); _branch.ID = 0; _branch.Name = _CompanyEntity.CompanyName; _branch.HODName = _CompanyEntity.CEOName; _branch.LogoPath = _CompanyEntity.LogoPath; _branch.IsActive = _CompanyEntity.IsActive; _branch.CreatedDate = _CompanyEntity.CreatedDate; _branch.CreatedBy = _CompanyEntity.CreatedBy; _branch.Company_ID = _company.ID; //_branch.Company_ID = Convert.ToUInt16(_CompanyOutPut["OutPut"]); _dbContext.BRANCHes.Add(_branch); if (_branch.ID > 0) { _dbContext.Entry(_branch).State = EntityState.Modified; } //_BranchOutPut = branchDataAccessLayer.CreateBranch(_branch); //int saveStatusBranch = Convert.ToUInt16(_BranchOutPut["saveStatus"]); //if (saveStatusBranch > 0) //{ CONTACT _contact = new CONTACT(); _contact.ID = 0; _contact.Name = _CompanyEntity.CompanyName; _contact.RoleId = 1; _contact.MobileNo = _CompanyEntity.MobileNo; _contact.PhoneNo = _CompanyEntity.PhoneNo; _contact.Email = _CompanyEntity.Email; _contact.Password = _CompanyEntity.Password; _contact.IsActive = _CompanyEntity.IsActive; _contact.CreatedDate = _CompanyEntity.CreatedDate; _contact.CreatedBy = _CompanyEntity.CreatedBy; _contact.Company_ID = _company.ID; _contact.Branch_ID = _branch.ID; //_contact.Company_ID = Convert.ToUInt16(_CompanyOutPut["OutPut"]); //_contact.Branch_ID = Convert.ToUInt16(_BranchOutPut["OutPut"]); _dbContext.CONTACTs.Add(_contact); if (_contact.ID > 0) { _dbContext.Entry(_contact).State = EntityState.Modified; } // _ContactOutPut = contactDataAccessLayer.CreateContact(_contact); //int saveStatusContact = Convert.ToUInt16(_BranchOutPut["saveStatus"]); //if (saveStatusContact > 0) //{ //*************to update branch and company tablw with contact id //TalentTopperEntities _dbContext = new TalentTopperEntities(); //_branch.Contact_Id = Convert.ToUInt16(_contact.ID); //_dbContext.Entry(_branch).State = EntityState.Modified; //_company.Contact_Id = Convert.ToUInt16(_contact.ID); //_dbContext.Entry(_company).State = EntityState.Modified; _dbContext.SaveChanges(); //} //} //} //} return(true); }