public ActionResult Create() { var benefitForm = new CreateBenefitForm(); benefitForm.BranchOfficesSelected = _branchOfficeService.GetByShopId(_currentUser.Shop.Id).Select(bo => bo.Id); return(View(benefitForm)); }
public ActionResult Index() { var shopId = _currentUser.Shop.Id; var branchOffices = _branchOfficeService.GetByShopId(shopId); var shop = _shopService.GetById(shopId); var shopBranchOfficesModel = new ShopBranchOfficesModel(shop, branchOffices); return(View(shopBranchOfficesModel)); }
public bool IsBenefitAvailableForBranchOffice(int benefitId, int branchOfficeId) { var benefit = Uow.Benefits.Get(b => b.Id == benefitId, b => b.BenefitBranchOffices); var branchOffice = _branchOfficeService.GetById(branchOfficeId); if (benefit == null || branchOffice == null) { throw new NotFoundException("No se encontro el beneficio"); } if (!_branchOfficeService.GetByShopId(branchOffice.Shop.Id).Any()) { return(false); } return(benefit.BenefitBranchOffices.Any(bo => bo.BranchOfficeId == branchOfficeId)); }
public ActionResult Detail(int id) { var benefit = _benefitService.GetById(id); if (benefit == null) { return(HttpNotFound()); } if (benefit.StatusId == StatusEnum.Approved) { var shop = _shopService.GetById(benefit.ShopId); var images = _benefitFileService.GetByBenefitId(benefit.Id); var branchOffices = _branchOfficeService.GetByShopId(benefit.ShopId); var benefitDetailModel = new BenefitDetailModel(benefit, shop, images, branchOffices); return(View(benefitDetailModel)); } else { throw new HttpException(404, "Not found"); } }