コード例 #1
0
        public void WhenCompanyIsCreated_CompanyExists()
        {
            _companyService.AddCompany("SEALAND", "SEA");
            var companyDto = _companyService.GetCompanyBySymbol("SEA");

            //Company exists if returned value is not null
            Assert.IsNotNull(companyDto);
        }
コード例 #2
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogDebug("Beginning import of demo data...");
            var amazonDto     = _companyService.AddCompany("Amazon", "AMZN");
            var blackfinchDto = _companyService.AddCompany("Blackfinch Group", "BLKFNCH");
            var teslaDto      = _companyService.AddCompany("Tesla", "TSLA");

            _logger.LogDebug("Companies added...");

            _companyService.IssueShares(amazonDto, 40, 100000);
            _companyService.IssueShares(blackfinchDto, 60, 600);
            _companyService.IssueShares(teslaDto, 420, 10000);
            //Auto list shares sell ?

            return(Task.CompletedTask);
        }
コード例 #3
0
        public async Task <IActionResult> AddCompany(Dtos.CompanyDto Company)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }

            var result = companyService.AddCompany(Company);

            if (!result)
            {
                return(BadRequest("Error saving products"));
            }

            //var client1 = new SectorApiClient.SectorApiClient("https://localhost:57532"); //tried it, not working, call it from UI itself.
            //SectorApiClient.CompanyDto comp1 = new SectorApiClient.CompanyDto()
            //{
            //    CompanyCode = Company.CompanyCode,
            //    CompanyName = Company.CompanyName,
            //    Sector = Company.Sector,
            //    Turnover = Company.Turnover
            //};
            //await client1.CompanyAsync(comp1) ;

            return(StatusCode(201));
        }
コード例 #4
0
        public async Task <ApiDataResponse <CompanyDTO> > AddCompany(CompanyDTO company)
        {
            await companyService.AddCompany(company);

            return(new ApiDataResponse <CompanyDTO>(company));
            //ASK ?????CreatedAtAction(nameof(GetAllCompanys)
        }
コード例 #5
0
        public IActionResult Post([FromBody] Company company)
        {
            logger.LogInformation("Accept POST Company");
            if (company == null)
            {
                return(BadRequest(JsonConvert.SerializeObject("invalid company object")));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                companyService.AddCompany(company);
            }
            catch (ServiceException ex)
            {
                logger.LogError(ex.Message);
                return(BadRequest(JsonConvert.SerializeObject("Server error")));
            }

            logger.LogInformation(JsonConvert.SerializeObject("Company was added from POST method"));
            return(Ok(company));
        }
コード例 #6
0
 public ActionResult Add(CompanyModel company)
 {
     if (company != null)
     {
         companyService.AddCompany(company);
     }
     return(RedirectToAction("Index"));
 }
コード例 #7
0
        public IActionResult Post([FromBody] CompanyDto company)
        {
            if (ModelState.IsValid && companyService.AddCompany(company) != null)
            {
                return(Ok(company));
            }

            return(BadRequest());
        }
コード例 #8
0
 public IActionResult CreateCompany(Company company)
 {
     if (!ModelState.IsValid)
     {
         return(View("CreateCompany"));
     }
     _companyService.AddCompany(company);
     return(RedirectToAction("Index"));
 }
コード例 #9
0
        public async Task <IActionResult> Create(Company companies)
        {
            if (ModelState.IsValid)
            {
                await _companyService.AddCompany(companies);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(companies));
        }
コード例 #10
0
        public IActionResult AddCompany([FromBody] CompanyDto company)
        {
            if (ModelState.IsValid)
            {
                _companyService.AddCompany(company);
                return(StatusCode(StatusCodes.Status201Created));
            }

            return(BadRequest());
        }
コード例 #11
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            // Set up companies
            _companyService.AddCompany(new Company("AMZN"));
            _companyService.AddCompany(new Company("TSLA"));
            _companyService.AddCompany(new Company("BLKFNCH"));

            // Set up company initial shares
            _companyService.IssueShares("AMZN", 100000, 40);
            _companyService.IssueShares("TSLA", 10000, 200);
            _companyService.IssueShares("BLKFNCH", 600, 60);

            // Set up starting orders
            _orderService.AddOrder(new Order("AMZN", 40, 40, 100, OrderType.Buy));
            _orderService.AddOrder(new Order("TSLA", 200, 200, 2000, OrderType.Buy));
            _orderService.AddOrder(new Order("BLKFNCH", 60, 60, 300, OrderType.Buy));

            return(Task.CompletedTask);
        }
コード例 #12
0
        public IActionResult AddCompany([FromBody] CompanyDto companyDto)
        {
            if (companyDto == null)
            {
                return(BadRequest("Invalid model"));
            }
            var result = _companyService.AddCompany(companyDto);

            return(Ok(result));
        }
コード例 #13
0
ファイル: CompanyController.cs プロジェクト: bolteq/whManager
        public async Task <IActionResult> SetCompany([FromBody] Company company)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var newCompany = await _companyService.AddCompany(company);

            return(Ok(newCompany));
        }
コード例 #14
0
 public IActionResult AddCompany(Company company)
 {
     try
     {
         return(Ok(_companyService.AddCompany(company)));
     }
     catch (Exception e)
     {
         return(StatusCode(500, e.Message));
     }
 }
コード例 #15
0
 public IActionResult CreateCompany([FromBody] CompanyModel company)
 {
     try
     {
         companyService.AddCompany(company.Name);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.ToString()));
     }
 }
コード例 #16
0
 public ActionResult <CompanyDto> AddCompany(string name, string symbol)
 {
     if (_companyService.GetCompanyBySymbol(symbol) != null)
     {
         return(NotFound($"Company already exists with symbol: '{symbol}'"));
     }
     if (_companyService.GetCompanyByName(name) != null)
     {
         return(NotFound($"Company already exists with name: '{name}'"));
     }
     return(_companyService.AddCompany(name, symbol));
 }
コード例 #17
0
        public IActionResult AddCompanyToDatabase([FromBody] DropDownRequest model)
        {
            var _Entity = new Integrator.Models.Domain.Companies.Company()
            {
                CompanyName = CommonHelper.CapitaliseAllWords(model.TEXT)
            };

            _companyService.AddCompany(_Entity);

            // return Json(new SelectList(cboOptions, "CoreSkillCategoryID", "CoreSkillCategoryName"));
            return(Json(_Entity));
        }
コード例 #18
0
        public void Setup()
        {
            // TODO: Mock the company context and order context so it doesn't use a "real" database
            var companyContext = new CompanyContext();
            var orderContext   = new OrderContext();

            _companyService = new CompanyService(companyContext, orderContext);
            _orderService   = new OrderService(orderContext, companyContext);


            _existingCompany = new Company("TSTCMPNY");
            _companyService.AddCompany(_existingCompany);
        }
コード例 #19
0
        public ActionResult Create(CompanyViewModel company)
        {
            try
            {
                companyService.AddCompany(company);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #20
0
        public async Task <IActionResult> AddCompany(AddCompanyViewModel companyModel)
        {
            if (companyModel == null)
            {
                return(BadRequest("Object of type company is null"));
            }
            if (ModelState.IsValid)
            {
                var company = AddCompanyToCompanyDTOMapper.Instance.Map(companyModel);
                await companyService.AddCompany(company);

                return(RedirectToAction(nameof(GetAllCompanies)));
            }
            return(View());
        }
コード例 #21
0
        public JsonResult AddCompany(string name)
        {
            var company = _companyService.AddCompany(name);

            if (company != null)
            {
                var jsonModel = JsonConvert.SerializeObject(company);
                return(Json(new { success = true, jsonModel }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var jsonModel = "Такая компания уже существует!";
                return(Json(new { success = false, jsonModel }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #22
0
        public IActionResult AddCompany(AddCompanyDto request)
        {
            if (!ModelState.IsValid)
            {
                //return
            }
            var company = new Company
            {
                Introduction = request.Introduction,
                Name         = request.Name
            };

            _companyService.AddCompany(request);
            return(Ok());
        }
コード例 #23
0
        public async Task <IActionResult> CompanyAdd(CompaniesDto model)
        {
            if (ModelState.IsValid)
            {
                await _companyService.AddCompany(model);

                return(RedirectToAction("CompanyList", "Company"));
            }
            else
            {
                ModelState.AddModelError("", "Kayıt Ederken Hata Oluştu");
            }

            return(View());
        }
コード例 #24
0
        public IHttpActionResult AddNewCompany(CompanyModel data)
        {
            var result = _companyService.AddCompany(data);

            if (result.status == EnumJsendStatus.success.ToString())
            {
                return(Ok(result));
            }

            string resultString = JsonConvert.SerializeObject(result, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });


            return(BadRequest(resultString));
        }
コード例 #25
0
ファイル: CompanyController.cs プロジェクト: birman/MusiSoft
        public IHttpActionResult PostCompany(CompanyViewModel company)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (companyService.AddCompany(company))
            {
                return(Ok(company));
            }
            else
            {
                return(Content(HttpStatusCode.BadRequest, "Company already exists"));
            }
        }
コード例 #26
0
        public ActionResult AddCompany([FromBody] AddCompanyModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var result = _companyService.AddCompany(model);
                return(Ok(result));
            }
            catch (ArgumentException e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message));
            }
        }
コード例 #27
0
        public IActionResult AddCompany(CompanyDto company)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }

            var result = companyService.AddCompany(company);

            if (!result)
            {
                return(BadRequest("Error saving products"));
            }

            //return CreatedAtRoute("GetProductById", new { id = obj.ID });
            return(StatusCode(201));
        }
        public void WhenAddingACompany_TheNumberOfCompaniesReturnedIsIncreased()
        {
            // Arrange
            var numberOfCompaniesBefore = _companyService.GetCompanies().Count();

            // Act
            _companyService.AddCompany(new Company("TSTCMPNY"));

            // Assert
            var numberOfCompaniesAfter = _companyService.GetCompanies().Count();

            Assert.AreEqual(numberOfCompaniesBefore + 1, numberOfCompaniesAfter);
        }
コード例 #29
0
        public string Execute(IList <string> parameters)
        {
            string name;

            try
            {
                name = parameters[0];
            }
            catch
            {
                throw new ArgumentException("Failed to parse AddCompany command parameters.");
            }

            Guard.WhenArgument(name, "Company name can not be null!").IsNullOrEmpty().Throw();

            var company = this.SportscardFactory.CreateCompanyDto(name);

            companyService.AddCompany(company);

            return($"\"{name}\" company was added to database.");
        }
コード例 #30
0
        public async Task <IActionResult> Post([FromBody] CompanyPostRequest request)
        {
            try
            {
                if (request == null)
                {
                    return(BadRequest(request));
                }

                await _companyService.AddCompany(new Application.Entities.CompanyEntity()
                {
                    Cnpj         = request.Cnpj,
                    SocialReason = request.SocialReason,
                    TradingName  = request.TradingName
                });

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(request));
            }
        }