public IActionResult SaveCompany([FromBody] CompanyDTO companyDTO) { try { if (ModelState.IsValid) { var co = _serviceAppCompany.Find(x => x.CompanyName.ToUpper().Equals(companyDTO.CompanyName.ToUpper())).FirstOrDefault(); if (co != null) { var re1 = _handleMessageUser.Add(Application.Enum.HandleMessageType.Error, "Company already exists!", null); return(Ok(re1)); } else { var company = _mapper.Map <Company>(companyDTO); _serviceAppCompany.Add(company); var re = _handleMessageUser.Add(Application.Enum.HandleMessageType.Success, "Company was added successfully!", null); return(Ok(re)); } } else { var result = _handleMessageUser.Add(Application.Enum.HandleMessageType.Error, "Problem to register company!", null); return(Ok(result)); } } catch (Exception ex) { var result = _handleMessageUser.Add(Application.Enum.HandleMessageType.InternalErrors, "Something went wrong: !" + ex.ToString(), null); return(Ok(result)); } }
public int UpdateCompany(CompanyDTO company) { using (var context = new PizzeriaMasterpieceEntities()) { var currentCompany = context.Companies.Find(company.CompanyId); if (!string.IsNullOrWhiteSpace(company.Name)) { currentCompany.Name = company.Name; } if (!string.IsNullOrWhiteSpace(company.RUC)) { currentCompany.Name = company.RUC; } if (!string.IsNullOrWhiteSpace(company.Address)) { currentCompany.Name = company.Address; } if (!string.IsNullOrWhiteSpace(company.PhoneNumber)) { currentCompany.Name = company.PhoneNumber; } context.SaveChanges(); return(currentCompany.CompanyId); } }
public CallRateProcessing( CompanyDTO company, ILogService log, IDbFactory dbFactory, ITime time) { _company = company; _log = log; _time = time; _dbFactory = dbFactory; _weightService = new WeightService(); var messageService = new SystemMessageService(log, time, dbFactory); var serviceFactory = new ServiceFactory(); var actionService = new SystemActionService(log, time); var rateProviders = serviceFactory.GetShipmentProviders(log, time, dbFactory, _weightService, company.ShipmentProviderInfoList, null, null, null, null); _rateService = new RateService(dbFactory, log, time, _weightService, messageService, company, actionService, rateProviders); }
protected override void RunCallback() { CompanyDTO company = null; var dbFactory = new DbFactory(); var time = new TimeService(dbFactory); var log = GetLogger(); var now = time.GetAppNowTime(); if (!time.IsBusinessDay(now)) { return; } using (var db = dbFactory.GetRDb()) { company = db.Companies.GetByIdWithSettingsAsDto(CompanyId); } var autoPurchaseTime = AppSettings.OverdueAutoPurchaseTime; var companyAddress = new CompanyAddressService(company); var addressService = new AddressService(null, companyAddress.GetReturnAddress(MarketIdentifier.Empty()), companyAddress.GetPickupAddress(MarketIdentifier.Empty())); //Checking email service, sent test message var emailSmtpSettings = SettingsBuilder.GetSmtpSettingsFromCompany(company, AppSettings.IsDebug, AppSettings.IsSampleLabels); var emailService = new EmailService(GetLogger(), emailSmtpSettings, addressService); var checker = new AlertChecker(log, time, dbFactory, emailService, company); using (var db = dbFactory.GetRWDb()) { checker.CheckOverdue(db, now, autoPurchaseTime); } }
public WooCommerceOrdersSynchronizer(ILogService log, IMarketApi api, CompanyDTO company, ISettingsService settings, ISyncInformer syncInfo, IList <IShipmentApi> rateProviders, IQuantityManager quantityManager, IEmailService emailService, IOrderValidatorService validatorService, IOrderHistoryService orderHistoryService, ICacheService cacheService, ISystemActionService systemAction, ICompanyAddressService companyAddress, ITime time, IWeightService weightService, ISystemMessageService messageService) : base(log, api, company, settings, syncInfo, rateProviders, quantityManager, emailService, validatorService, orderHistoryService, cacheService, systemAction, companyAddress, time, weightService, messageService) { }
static public IEmailImapSettings GetImapSettingsFromCompany(CompanyDTO company) { var settings = new EmailImapSettings(); if (company == null) { return(settings); } var smtpSettings = company.EmailAccounts.FirstOrDefault(e => e.Type == (int)EmailAccountType.Imap); if (smtpSettings == null) { return(settings); } settings.ImapHost = smtpSettings.ServerHost; settings.ImapPort = smtpSettings.ServerPort; settings.ImapUsername = smtpSettings.UserName; settings.ImapPassword = smtpSettings.Password; settings.AcceptingToAddresses = (smtpSettings.AcceptingToAddresses ?? "").Split(";,".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); settings.MaxProcessMessageErrorsCount = Int32.Parse(AppSettings.Support_MaxProcessMessageErrorsCount); settings.ProcessMessageThreadTimeout = TimeSpan.FromSeconds(Int32.Parse(AppSettings.Support_ProcessMessageThreadTimeoutSecond)); settings.AttachmentFolderPath = smtpSettings.AttachmentDirectory; settings.AttachmentFolderRelativeUrl = smtpSettings.AttachmentFolderRelativeUrl; settings.IsDebug = AppSettings.IsDebug; return(settings); }
public async Task <CompanyDTO> CompanyCreate([FromBody] CompanyDTO companyDTO, [FromQuery] string vkToken) { _companyDTOValidator.ValidateAndThrow(companyDTO); var result = await _companyService.CreateCompany(companyDTO, vkToken); return(result); }
public static MemoryStream ExportToExcelUS(ILogService log, ITime time, IMarketCategoryService categoryService, IHtmlScraperService htmlScraper, IMarketApi marketApi, IUnitOfWork db, CompanyDTO company, string asin, MarketType market, string marketplaceId, bool useStyleImage, out string filename) { var models = GetItemsFor(log, time, categoryService, htmlScraper, marketApi, db, company, asin, ExportToExcelMode.Normal, null, market, marketplaceId, useStyleImage ? UseStyleImageModes.StyleImage : UseStyleImageModes.ListingImage, out filename); return(ExcelHelper.ExportIntoFile(HttpContext.Current.Server.MapPath(USTemplatePath), "Template", models)); }
public async Task <CompanyDTO> UpdateCompany(CompanyDTO companyDTO, string vkToken) { var company = _mapper.Map <CompanyDTO, Company>(companyDTO); var companyFromDb = await _context.Companies.WhereIsNotDeleted(x => x.Id == companyDTO.Id).FirstOrDefaultAsync(); if (companyFromDb == null) { throw new BadRequestException(ExceptionCodes.COMMON_NOT_EXIST); } if (companyFromDb.Email != companyDTO.Email) { throw new BusinessLogicException(ExceptionCodes.READONLY_FIELD); } _context.SetValuesApp(companyFromDb, company); var vkId = await _vkService.GetCompanyIdFromVk(companyDTO.VkStr, vkToken); companyFromDb.VkId = vkId; var userFromDb = await _context.Users.WhereIsNotDeleted(x => x.CompanyId == companyFromDb.Id).FirstAsync(); if (!PasswordHelper.VerifyPassword(companyDTO.Password, userFromDb.PasswordHash)) { var newPasswordHash = PasswordHelper.GetPasswordHash(companyDTO.Password); userFromDb.PasswordHash = newPasswordHash; } await _context.SaveChangesAsync(); var updatedCompanyDTO = _mapper.Map <Company, CompanyDTO>(companyFromDb); return(updatedCompanyDTO); }
public async Task UpdateCompany(CompanyDTO company) { var companyMapped = CompanyDtoToEntityMapper.Instance.MapBack(company); unitOfWork.CompanyRepository.Update(companyMapped); await unitOfWork.Save(); }
protected override void RunCallback() { CompanyDTO company = null; var dbFactory = new DbFactory(); var time = new TimeService(dbFactory); var settings = new SettingsService(dbFactory); var log = GetLogger(); using (var db = dbFactory.GetRDb()) { company = db.Companies.GetByIdWithSettingsAsDto(CompanyId); } var companyAddress = new CompanyAddressService(company); var addressService = new AddressService(null, companyAddress.GetReturnAddress(MarketIdentifier.Empty()), companyAddress.GetPickupAddress(MarketIdentifier.Empty())); var emailSmtpSettings = SettingsBuilder.GetSmtpSettingsFromCompany(company, AppSettings.IsDebug, AppSettings.IsSampleLabels); var actionService = new SystemActionService(log, time); var emailService = new EmailService(log, emailSmtpSettings, addressService); var lastSyncDate = settings.GetOrdersAdjustmentDate(_api.Market, _api.MarketplaceId); using (var db = dbFactory.GetRWDb()) { LogWrite("Last sync date=" + lastSyncDate); if (!lastSyncDate.HasValue || (time.GetUtcTime() - lastSyncDate) > _betweenProcessingInverval) { var updater = new BaseOrderRefundService(_api, actionService, emailService, log, time); updater.ProcessRefunds(db, null); settings.SetOrdersAdjustmentDate(time.GetUtcTime(), _api.Market, _api.MarketplaceId); } } }
public static CompanyDTO MapCompanyToCompanyDTO(Company cmp) { if (cmp != null) { CompanyDTO newcmp = new CompanyDTO() { CompanyId = cmp.CompanyId, Name = cmp.Name, Phone = cmp.Phone, Mail = cmp.Mail, Street = cmp.Street, HouseNumber = cmp.HouseNumber, City = cmp.City, PostalCode = cmp.PostalCode, Country = cmp.Country, Site = cmp.Site, Contract = cmp.Contract }; newcmp.CompanyMembers = cmp.CompanyMembers.Select(u => User.MapUserToUserDTO(u, u.Categories.Select(c => c.Category).ToList())); return(newcmp); } else { return(null); }; }
public CompanyDTO SaveCompany(CompanyDTO company) { if (company == null) { return(null); } if (string.IsNullOrWhiteSpace(company.FullName)) { throw new ArgumentException("Full name is missing."); } if (string.IsNullOrWhiteSpace(company.ShortName)) { throw new ArgumentException("Short name is missing"); } Company savedCompany = null; if (company.Id.HasValue) { savedCompany = companiesRepository.Update(Company.Hydrate(company)); } else { savedCompany = companiesRepository.Insert(Company.Hydrate(company)); } if (savedCompany != null) { return(savedCompany.getDTO()); } else { return(null); } }
public CallEBayProcessing(ILogService log, ITime time, ICacheService cacheService, IDbFactory dbFactory, IStyleManager styleManager, eBayApi eBayApi, IEmailService emailService, CompanyDTO company) { _log = log; _time = time; _dbFactory = dbFactory; _cacheService = cacheService; _styleManager = styleManager; _descriptionTemplatePath = Path.Combine(AppSettings.TemplateDirectory, TemplateHelper.EBayDescriptionTemplateName); _descriptionMultiListingTemplatePath = Path.Combine(AppSettings.TemplateDirectory, TemplateHelper.EBayDescriptionMultiListingTemplateName); _eBayApi = eBayApi; _company = company; _emailService = emailService; _actionService = new SystemActionService(_log, _time); _htmlScraper = new HtmlScraperService(log, time, dbFactory); var itemHistoryService = new ItemHistoryService(_log, _time, _dbFactory); _barcodeService = new BarcodeService(log, time, dbFactory); _autoCreateListingService = new AutoCreateEBayListingService(_log, _time, dbFactory, cacheService, _barcodeService, _emailService, itemHistoryService, AppSettings.IsDebug); }
protected override void RunCallback() { var dbFactory = new DbFactory(); var time = new TimeService(dbFactory); var log = GetLogger(); var orderHistoryService = new OrderHistoryService(log, time, dbFactory); var serviceFactory = new ServiceFactory(); CompanyDTO company = null; using (var db = dbFactory.GetRDb()) { company = db.Companies.GetByIdWithSettingsAsDto(CompanyId); } var addressCheckServices = serviceFactory.GetAddressCheckServices(log, time, dbFactory, company.AddressProviderInfoList); var companyAddress = new CompanyAddressService(company); var addressService = new AddressService(addressCheckServices, companyAddress.GetReturnAddress(MarketIdentifier.Empty()), companyAddress.GetPickupAddress(MarketIdentifier.Empty())); var addressChecker = new AddressChecker(log, dbFactory, addressService, orderHistoryService, time); using (var db = dbFactory.GetRWDb()) { addressChecker.RecheckAddressesWithException(); } }
public CompanyDTO CompanySearchById(int CompanyId) { CompanyDTO oCompanyDTO = new CompanyDTO(); try { using (HttpClient client = new HttpClient()) { string path = "Company/CompanySearchById?CompanyId=" + CompanyId; client.BaseAddress = new Uri(GlobalValues.BaseUri); HttpResponseMessage responce = client.GetAsync(path).Result; if (responce.IsSuccessStatusCode) { var value = responce.Content.ReadAsStringAsync().Result; oCompanyDTO = JsonConvert.DeserializeObject <CompanyDTO>(value); } } } catch (Exception ex) { throw ex; } return(oCompanyDTO); }
public bool UpdateCompanyData(CompanyDTO oCompanyDTO) { bool ReturnValue = false; try { using (HttpClient client = new HttpClient()) { string path = "Company/UpdateCompanyData"; client.BaseAddress = new Uri(GlobalValues.BaseUri); var json = JsonConvert.SerializeObject(oCompanyDTO); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage responce = client.PostAsync(path, content).Result; if (responce.IsSuccessStatusCode) { string jsnString = responce.Content.ReadAsStringAsync().Result; ReturnValue = JsonConvert.DeserializeObject <bool>(jsnString); } } } catch (Exception ex) { string message = ex.Message; } return(ReturnValue); }
public void Login_CompanyFound_CompanyHasName() { Company company = new Company(); CompanyDTO dto = company.Login(DefaultCompanyEmail, "1234"); Assert.IsNotNull(!String.IsNullOrEmpty(dto.Name)); }
public async Task <ActionResult <string> > PutCompany([FromBody] CompanyDTO company, long id) { try { var results = await _companyManager.Update(company, id); if (!string.IsNullOrEmpty(results.Result)) { return(Ok(results.Result)); } else if (results.StatusCode == HttpStatusCode.BadRequest) { return(BadRequest(results.Message)); } else if (results.StatusCode == HttpStatusCode.NotFound) { return(NotFound(results.Message)); } else { return(StatusCode((int)HttpStatusCode.InternalServerError, results.Message)); } } catch (Exception ex) { // Log data return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); } }
public void Login_CompanyFound_CompanyIsNotNull() { Company company = new Company(); CompanyDTO dto = company.Login(DefaultCompanyEmail, "1234"); Assert.IsNotNull(dto); }
public static IEmailImapSettings GetImapSettingsFromCompany(CompanyDTO company, int maxProcessMessageErrorsCount, int processMessageThreadTimeoutSecond) { var emailAccount = company.EmailAccounts.FirstOrDefault(a => a.Type == (int)EmailAccountType.Imap); if (emailAccount == null) { return(null); } var settings = new EmailImapSettings(); settings.ImapHost = emailAccount.ServerHost; settings.ImapPort = emailAccount.ServerPort; settings.ImapUsername = emailAccount.UserName; settings.ImapPassword = emailAccount.Password; settings.AcceptingToAddresses = (emailAccount.AcceptingToAddresses ?? "").Split(";,".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); settings.MaxProcessMessageErrorsCount = maxProcessMessageErrorsCount; settings.ProcessMessageThreadTimeout = TimeSpan.FromSeconds(processMessageThreadTimeoutSecond); settings.AttachmentFolderPath = emailAccount.AttachmentDirectory; settings.AttachmentFolderRelativeUrl = emailAccount.AttachmentFolderRelativeUrl; return(settings); }
public static IEmailSmtpSettings GetSmtpSettingsFromCompany(CompanyDTO company, bool isDebug, bool isSampleMode) { var emailAccount = company.EmailAccounts.FirstOrDefault(a => a.Type == (int)EmailAccountType.Smtp); if (emailAccount == null) { return(null); } var settings = new EmailSmtpSettings(); settings.SystemEmailPrefix = company.CompanyName; settings.SmtpHost = emailAccount.ServerHost; settings.SmtpPort = emailAccount.ServerPort; settings.SmtpUsername = emailAccount.UserName; settings.SmtpPassword = emailAccount.Password; settings.SmtpFromEmail = emailAccount.FromEmail; settings.SmtpFromDisplayName = emailAccount.DisplayName; settings.IsDebug = isDebug; settings.IsSampleMode = isSampleMode; return(settings); }
public void EditCompany_ShouldEditRecord() { // Arrange var context = this.GetDbContext(); this.PopulateData(context); // Act var service = new CompanyLogic(context, mapper); var newCompany = new CompanyDTO { Id = 5, Name = "Lidivo3 Edited", Description = "Grocery store3", Headquarters = "Sofia3", Employees = new List <EmployeeDTO>() }; service.EditCompany(newCompany); var company = context.Companies.Find(5); // Assert Assert.NotNull(company); Assert.Equal("Lidivo3 Edited", company.Name); }
public async Task <IActionResult> PutCompany(long id, CompanyDTO companyDTO) { if (id != companyDTO.Id) { return(BadRequest()); } var company = await _context.Companies.FindAsync(id); if (company == null) { return(NotFound()); } company.Name = companyDTO.Name; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) when(!CompanyExists(id)) { return(NotFound()); } return(NoContent()); }
public async Task <ActionResult> AddOrUpdateCompany(CompanyDTO company) { if (ModelState.IsValid) { CompanyDTO savedOrUpdatedDTO = null; //Antager, at brugeren ikke har en virksomhed koblet op til sig her. if (!CurrentUser.IsCompanyValidated) { savedOrUpdatedDTO = await _accountservice.AddCompanyToAccount(CurrentUser.ID, company); } else { CompanyUpdateRequest request = new CompanyUpdateRequest { Company = company, AccountID = CurrentUser.ID }; savedOrUpdatedDTO = await _accountservice.UpdateCompanyInformation(request); } ViewBag.IsValidated = true; CurrentUser.AddCompanyInformation(savedOrUpdatedDTO); return(PartialView("CompanyManagement", savedOrUpdatedDTO)); } return(PartialView("CompanyManagement", ModelState)); }
public async Task <CompanyDTO> UpdateCompanyAsync(string id, CompanyDTO company) { if (company is null) { throw new HttpStatusException(400, "Etwas ist schiefgelaufen"); } if (!id.Equals(company.Id)) { throw new HttpStatusException(400, "Die mitgebene ID stimmt nicht mit der company überein"); } var companyToUpdate = await _companyRepository.GetCompanyByIdAsync(id); if (companyToUpdate is null) { throw new HttpStatusException(400, "Die mitgegebene Company existiert"); } companyToUpdate.Name = company.Name; await _companyRepository.UpdateAsync(companyToUpdate); return((CompanyDTO)companyToUpdate); }
//public string Disable(CompanyDTO client) //{ // if (client == null) // return GenericMessages.ObjectIsNull; // try // { // _clientRepository.Update(client); // _unitOfWork.Commit(); // return string.Empty; // } // catch (Exception exception) // { // return exception.Message; // } //} //public int Delete(string clientId) //{ // try // { // _clientRepository.Delete(clientId); // _unitOfWork.Commit(); // return 0; // } // catch (Exception exception) // { // return -1; // } //} public bool ObjectExists(CompanyDTO client) { var objectExists = false; var iDbContext = DbContextUtil.GetDbContextInstance(); try { var catRepository = new Repository <CompanyDTO>(iDbContext); var catExists = catRepository .Query() .Filter(bp => bp.DisplayName == client.DisplayName && bp.Id != client.Id) .Get() .FirstOrDefault(); if (catExists != null) { objectExists = true; } } finally { iDbContext.Dispose(); } return(objectExists); }
public WooCommerceOrdersSynchronizer(ILogService log, CompanyDTO company, ISyncInformer syncInfo, IList <IShipmentApi> rateProviders, ICompanyAddressService companyAddress, ITime time, IWeightService weightService, ISystemMessageService messageService) : base(log, null, company, null, syncInfo, rateProviders, null, null, null, null, null, null, companyAddress, time, weightService, messageService) { }
public IActionResult GetEmployeeJson() { CompanyDTO comp = new CompanyDTO(); var data = db.Employee.Select(r => new Employee_details { name = r.Name, employee_id = r.EmployeeId, department = r.Department, email = r.Email, direct_number = r.DirectNumber, skills = r.ItemsSkill.Select(x => x.Skills).ToList(), work_experience = r.WorkExperience.ToList(), office = r.Office.ToList() }).ToList(); comp.employees = data.ToArray(); var data2 = db.Company.Select(r => new Company_details { name = r.Name, address = r.Address, website = r.Website }).ToList(); comp.company = data2.ToArray(); return(Ok(comp)); }
static public IEmailSmtpSettings GetSmtpSettingsFromCompany(CompanyDTO company) { var settings = new EmailSmtpSettings(); if (company == null) { return(settings); } var smtpSettings = company.EmailAccounts.FirstOrDefault(e => e.Type == (int)EmailAccountType.Smtp); if (smtpSettings == null) { return(settings); } settings.SmtpHost = smtpSettings.ServerHost; settings.SmtpPort = smtpSettings.ServerPort; settings.SmtpUsername = smtpSettings.UserName; settings.SmtpPassword = smtpSettings.Password; settings.SmtpFromEmail = smtpSettings.FromEmail; settings.SmtpFromDisplayName = smtpSettings.DisplayName; settings.IsDebug = AppSettings.IsDebug; return(settings); }
//Method that creates new Company public bool CreateNewCompany(CompanyDTO CompanyNew) { bool check = false; using (TransactionScope transaction = new TransactionScope()) { try { Company CompanyIn = new Company(); //Data transfer to the new company CompanyIn.Name = CompanyNew.Name; using (var context = new RFQEntities()) { //Finding references for the Foreign Keys Category existingCategory = context.Categories.Single(p => p.CategoryID == CompanyNew.CategoryID); CompanyType existingCompanyType = context.CompanyTypes.Single(p => p.CompanyTypeID == CompanyNew.CompanyTypeID); //Adding refernces CompanyIn.Category = existingCategory; CompanyIn.CompanyType = existingCompanyType; if (CompanyIn.EntityState == EntityState.Detached) { context.Companies.AddObject(CompanyIn); } context.SaveChanges(); } } catch (Exception e) { transaction.Dispose(); check = false; return check; } transaction.Complete(); check = true; return check; } }
//Dory --- Method that gets all Companies to grid public List<CompanyDTO> GetCompanies() { List<CompanyDTO> CompanyList = new List<CompanyDTO>(); string path = "Category"; string path1 = "CompanyType"; using (var context = new RFQEntities()) { var results = (from comp in context.Companies.Include(path).Include(path1) select new { CompanyID = comp.CompanyID, CompanyName = comp.Name, CategoryID = comp.Category.CategoryID, CompanyCategory = comp.Category.Type, CompanyTypeID = comp.CompanyType.CompanyTypeID, CompanyType = comp.CompanyType.Type } ).ToList(); if (results.Count > 0) { foreach (var item in results) { CompanyDTO CompanyRow = new CompanyDTO(); CompanyRow.CompanyID = item.CompanyID; CompanyRow.Name = item.CompanyName; CompanyRow.CompanyTypeID = item.CompanyTypeID; CompanyRow.CategoryID = item.CategoryID; CompanyList.Add(CompanyRow); } } } return CompanyList; }
private HttpResponseMessage ProcessExistingCompanyRecord(HttpRequestMessage request, CompanyDTO cqDto, int contactId, string key, int companyId, int userId) { var ur = new CompanyRepository(); var user = new Company(); user = ur.GetById(contactId); var validationErrors = GetValidationErrors(ur, user, cqDto, companyId, userId); if (validationErrors.Any()) { return ProcessValidationErrors(request, validationErrors, key); } ur.Save(user); cqDto.Key = key; return request.CreateResponse(HttpStatusCode.Accepted, cqDto); }
//Get Company By ID Method public CompanyDTO GetCompanyByID(int CompanyID) { Company CompanySpecific = new Company(); string path = "Category"; string path1 = "CompanyType"; using (var context = new RFQEntities()) { CompanySpecific = (from comp in context.Companies.Include(path).Include(path1) where comp.CompanyID == CompanyID select comp).First(); } CompanyDTO CompanyToReturn = new CompanyDTO(); CompanyToReturn.CompanyID = CompanySpecific.CompanyID; CompanyToReturn.Name = CompanySpecific.Name; CompanyToReturn.CategoryID = CompanySpecific.Category.CategoryID; CompanyToReturn.CompanyTypeID = CompanySpecific.CompanyType.CompanyTypeID; return CompanyToReturn; }
private List<DbValidationError> GetValidationErrors(CompanyRepository pr, Company contact, CompanyDTO cqDto, int companyId, int userId) { contact.ProcessRecord(cqDto); return pr.Validate(contact); }
private HttpResponseMessage ProcessNewCompanyRecord(HttpRequestMessage request, CompanyDTO uDto, string key, int companyId, int userId) { var ur = new CompanyRepository(); var user = new Company(); var validationErrors = GetValidationErrors(ur, user, uDto, companyId, userId); if (validationErrors.Any()) { return ProcessValidationErrors(request, validationErrors, key); } user = ur.Save(user); uDto.Key = key; uDto.CompanyId = user.CompanyId.ToString(); var response = request.CreateResponse(HttpStatusCode.Created, uDto); response.Headers.Location = new Uri(Url.Link("Default", new { id = user.CompanyId })); return response; }