/// <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 }); }
public async Task <bool> AddOrganizationAsync(BLLOrganizationDTO organization) { await Uow.Organizations.AddAsync(OrganizationMapper.FromBLL(organization)); await Uow.SaveChangesAsync(); return(true); }
/// <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() }); }
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")); }