Esempio n. 1
0
        //
        // GET: /Companies/Details/5

        public ActionResult Details(int id)
        {
            var company          = _companyApp.GetById(id);
            var companyViewModel = Mapper.Map <Company, CompanyViewModel>(company);

            return(View(companyViewModel));
        }
        /// <summary>
        /// Create a new order
        /// </summary>
        /// <param name="orderCreateModel"></param>
        /// <returns></returns>
        public async Task <Guid> Create(OrderCreateModel orderCreateModel)
        {
            var customer = await _customerAppService.GetById(orderCreateModel.CustomerId);

            var company = await _companyAppService.GetById(orderCreateModel.CompanyId);

            var paymentType = await _paymentTypeAppService.GetById(orderCreateModel.PaymentMethodId);

            var address = await _addressAppService.GetById(orderCreateModel.AddressId);

            if (paymentType == null || customer == null || company == null || address == null)
            {
                throw new Exception("An error has occurred please try again.");
            }

            //Generate the order
            OrderDto model = new OrderDto(orderCreateModel, customer, company, address, paymentType);

            try
            {
                await _smtpEmailSender.SendAsync(
                    to : "*****@*****.**",
                    subject : "You have a new task!",
                    body : $"A new task is assigned for you: <b>test</b>",
                    isBodyHtml : true);
            }
            catch (Exception exception)
            {
                throw exception;
            }

            //We return the id so we can redirect to the orderitem page.
            return(await _repository.InsertAndGetIdAsync(ObjectMapper.Map <Models.Order>(model)));
        }
        // GET: Company/Details/5
        public ActionResult Details(Guid id)
        {
            var company = _companyAppService.GetById(id);

            if (company == default(CompanyViewModel))
            {
                return(HttpNotFound());
            }
            return(View(company));
        }
Esempio n. 4
0
        //
        // GET: /Companies/Details/1/name

        public ActionResult Details(int id, String seoName)
        {
            var comp = Mapper.Map <Company, CompanyViewModel>(_companyApp.GetById(id));

            // Redirect to proper name
            if (!seoName.Equals(comp.Name.SeoString()))
            {
                return(RedirectToActionPermanent("Details", new { id = id, seoName = comp.Name.SeoString() }));
            }

            return(View(comp));
        }
Esempio n. 5
0
        public async Task Should_Get_By_Id()
        {
            var company = await _companyAppService.GetAll(new Portal.Companies.Dto.GetAllFilterCompany()
            {
                Types = Portal.Companies.Type.Final
            });

            var id = company.Items.FirstOrDefault().Id;

            var result = await _companyAppService.GetById(id);

            result.ShouldNotBeNull();
        }
        public async Task <CompanyListModel> PrepareEditModal(Guid id)
        {
            var company = await _companyAppService.GetById(id);

            if (company == null)
            {
                throw new Exception("Id not found");
            }

            var countries = await _countryAppService.GetAll();

            var provinces = await _provinceAppService.GetAllByCountryId(company.CountryId);

            IEnumerable <SelectListItem> selectListCountry = countries.Select(x => new SelectListItem {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();
            IEnumerable <SelectListItem> selectListProvince = provinces.Select(x => new SelectListItem {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();

            selectListCountry.FirstOrDefault(x => x.Value == company.CountryId.ToString()).Selected   = true;
            selectListProvince.FirstOrDefault(x => x.Value == company.ProvinceId.ToString()).Selected = true;
            List <CompanyDto> companyList = new List <CompanyDto>();

            companyList.Add(company);
            var model = new CompanyListModel()
            {
                Companies = companyList,
                Countries = selectListCountry,
                Provinces = selectListProvince
            };

            return(model);
        }
        public async Task <IHttpActionResult> GetByIdAsync([FromUri] int id)
        {
            var companyEntity = await Task.Run(() => _companyAppService.GetById(id));

            if (companyEntity == null)
            {
                return(this.Ok());
            }

            var companyRead = new CompanyRead(companyEntity);

            return(this.Ok(companyRead));
        }
Esempio n. 8
0
        public IHttpActionResult GetById(long id)
        {
            try
            {
                var companyDto   = _companyAppService.GetById(id);
                var companyModel = Mapper.Map <CompanyModel>(companyDto);

                return(Ok(companyModel));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }