Ejemplo n.º 1
0
 /// <summary>
 /// Maps name
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 /// <exception cref="NotImplementedException"></exception>
 public static DALOrganizationDTO FromBLL(BLLOrganizationDTO dto)
 {
     return(new DALOrganizationDTO()
     {
         Name = dto.Name
     });
 }
Ejemplo n.º 2
0
        public async Task <bool> AddOrganizationAsync(BLLOrganizationDTO organization)
        {
            await Uow.Organizations.AddAsync(OrganizationMapper.FromBLL(organization));

            await Uow.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Maps id, name, Categories(id, name, Products(id, name, desc, price))
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 /// <exception cref="NullReferenceException"></exception>
 public static OrganizationDTO FromBLL(BLLOrganizationDTO dto)
 {
     if (dto == null)
     {
         throw new NullReferenceException("Can't map, BLLOrganizationDTO is null");
     }
     return(new OrganizationDTO()
     {
         Id = dto.Id,
         Name = dto.Name,
         Categories = dto.Categories
                      .Select(CategoryMapper.FromBLL)
                      .ToList()
     });
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create(CreateOrganizationViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var organization = new BLLOrganizationDTO
                {
                    Name = vm.Name
                };

                var result = await _bll.OrganizationsService.AddOrganizationAsync(organization);

                if (result == false)
                {
                    return(BadRequest("Something went wrong while adding the organization"));
                }
                return(RedirectToAction("Index", "Dashboard"));
            }

            return(BadRequest("Model invalid"));
        }