public void ForbiddenResource() { repo.Add(entity); repo.Save(); using (ClientUserManager manager = new ClientUserManager(new CustomUserStore(ctx))) { Assert.IsNull(repo.GetBookingStepBookingById(entity.Id, manager.FindByEmail("*****@*****.**").Id)); } }
protected override void DoPut(Client currentClient, BookingStepBooking entity, object param) { var origCopy = BookingStepBookingRepository.GetBookingStepBookingById(entity.Id, currentClient.Id); if (origCopy.BookingStepConfig.Id != entity.BookingStepConfig.Id) { entity.CurrentStep = BookingStepRepository.GetFirstBookingStep(entity.BookingStepConfig.Id, currentClient.Id); } if (origCopy.CurrentStep.Id != entity.CurrentStep.Id) { entity.MailSent = 0; ValidateBooking(entity); entity.DateCurrentStepChanged = DateTime.UtcNow; } }
public virtual MailLog MailSteps(Client currentClient, MailBookingModel model, object param) { ValidateNull <MailBookingModel>(model); MailLog log = new MailLog(); HomeConfig hc = null; Document body = null; List <Document> listAttachments = null; BookingStepBookingRepository.includes.Add("CurrentStep"); BookingStepBookingRepository.includes.Add("CurrentStep.Documents"); BookingStepBookingRepository.includes.Add("CurrentStep.MailTemplate"); BookingStepBookingRepository.includes.Add("Booking"); BookingStepBookingRepository.includes.Add("Booking.People"); BookingStepBooking b = BookingStepBookingRepository.GetBookingStepBookingById(model.BookingId, currentClient.Id); if (b == null) { validationDictionnary.AddModelError(TypeOfName.GetNameFromType <Booking>(), GenericError.FORBIDDEN_RESOURCE_OR_DOES_NO_EXIST); throw new ManahostValidationException(validationDictionnary); } HomeConfigRepository.includes.Add("DefaultMailConfig"); hc = HomeConfigRepository.GetHomeConfigById(b.HomeId, currentClient.Id); if (!((BookingStepBookingValidation)validation).MailStepValidation(validationDictionnary, currentClient, hc, b, model, param)) { throw new ManahostValidationException(validationDictionnary); } if (b.CurrentStep.MailTemplate == null) { validationDictionnary.AddModelError("CurrentStep.MailTemplate", GenericError.CANNOT_BE_NULL_OR_EMPTY); throw new ManahostValidationException(validationDictionnary); } body = DocumentRepository.GetDocumentById(b.CurrentStep.MailTemplate.Id, currentClient.Id); listAttachments = b.CurrentStep.Documents; if (hc.DefaultMailConfig != null) { SendMailUsingCustomMailAccount(hc.DefaultMailConfig, b, log, model.Password, GetMailBody(body, b.Home), MailUtils.GetAttachments(listAttachments, b.Home)); } else { SendMailUsingManahostMailAccount(b, log, GetMailBody(body, b.Home), MailUtils.GetAttachments(listAttachments, b.Home)); } repo.Add <MailLog>(log); repo.Update(b); repo.Save(); return(log); }