public CardWorkCrudController() { Post("/api/v1/card/work/submit", _ => { var errors = ValidationProcessor.Process(Request, new IValidatorRule[] { new ShouldHaveParameters(new[] { "card_guid", "work_type_guid", "proof" }), new ExistsInTable("card_guid", "cards", "guid"), new ExistsInTable("work_type_guid", "project_work_types", "guid"), }); if (errors.Count > 0) { return(HttpResponse.Errors(errors)); } var me = UserRepository.Find(CurrentRequest.UserId); var card = CardRepository.FindByGuid(GetRequestStr("card_guid")); var workType = ProjectWorkTypeRepository.FindBy( "guid", GetRequestStr("work_type_guid") ); var work = CardWorkRepository.CreateAndGet( me, card, workType, GetRequestStr("proof") ); return(HttpResponse.Item("work_item", new CardWorkTransformer().Transform(work))); }); }
public static CardWork Create(ProjectWorkType workType, CardModel card = null, UserModel user = null) { user ??= UserFaker.Create(); card ??= CardFaker.Create(); return(CardWorkRepository.CreateAndGet(user, card, workType, "some proof like link or something")); }