public void TestCreateInterestPointCategoryAsync() { BoraNowSeeder.Seed(); var ipcipbo = new InterestPointCategoryInterestPointBusinessObject(); var ipbo = new InterestPointBusinessObject(); var cipbo = new CategoryInterestPointBusinessObject(); var pbo = new ProfileBusinessObject(); var profile = new Profile("II", "AA"); pbo.Create(profile); var c = new CompanyBusinessObject(); var company = new Company("A", "B", "12345678", "1234567", profile.Id); c.Create(company); var interestPoint = new InterestPoint("a", "b", "c", "d", "e", "f", "g", true, true, company.Id); var category = new CategoryInterestPoint("vegan"); var interestPointCategory = new InterestPointCategoryInterestPoint(interestPoint.Id, category.Id); ipbo.Create(interestPoint); cipbo.Create(category); var resCreate = ipcipbo.CreateAsync(interestPointCategory).Result; var resGet = ipcipbo.ReadAsync(interestPointCategory.Id).Result; Assert.IsTrue(resGet.Success && resCreate.Success && resGet.Result != null); }
public static CategoryInterestPointViewModel Parse(CategoryInterestPoint categoryInterestPoint) { return(new CategoryInterestPointViewModel() { Id = categoryInterestPoint.Id, Name = categoryInterestPoint.Name }); }
public ActionResult Create([FromBody] CategoryInterestPointViewModel vm) { var c = new CategoryInterestPoint(vm.Name); var res = _bo.Create(c); var code = res.Success ? HttpStatusCode.OK : HttpStatusCode.InternalServerError; return(new ObjectResult(code)); }
public void TestCreateCategoryInterestPoint() { BoraNowSeeder.Seed(); var cipbo = new CategoryInterestPointBusinessObject(); var categoryInterestPoint = new CategoryInterestPoint("B"); var resCreate = cipbo.Create(categoryInterestPoint); var resGet = cipbo.Read(categoryInterestPoint.Id); Assert.IsTrue(resGet.Success && resCreate.Success && resGet.Result != null); }
public void TestUpdateInterestpointCategoryAsync() { BoraNowSeeder.Seed(); var cipbo = new CategoryInterestPointBusinessObject(); var resList = cipbo.List(); var item = resList.Result.FirstOrDefault(); var categoryInterestPoint = new CategoryInterestPoint("C"); item.Name = categoryInterestPoint.Name; var resUpdate = cipbo.UpdateAsync(item).Result; resList = cipbo.ListAsync().Result; Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().Name == categoryInterestPoint.Name); }
public OperationResult Delete(CategoryInterestPoint category) { try { _dao.Delete(category); return(new OperationResult() { Success = true }); } catch (Exception e) { return(new OperationResult() { Success = true, Exception = e }); } }
public async Task <OperationResult> DeleteAsync(CategoryInterestPoint category) { try { await _dao.DeleteAsync(category); return(new OperationResult() { Success = true }); } catch (Exception e) { return(new OperationResult() { Success = true, Exception = e }); } }
public void TestUpdateInterestpointCategoryAsync() { BoraNowSeeder.Seed(); var ipcipbo = new InterestPointCategoryInterestPointBusinessObject(); var resList = ipcipbo.ListAsync().Result; var item = resList.Result.FirstOrDefault(); var ipbo = new InterestPointBusinessObject(); var cipbo = new CategoryInterestPointBusinessObject(); var pbo = new ProfileBusinessObject(); var profile = new Profile("II", "AA"); pbo.Create(profile); var c = new CompanyBusinessObject(); var company = new Company("A", "B", "12345678", "1234567", profile.Id); c.Create(company); var interestPoint = new InterestPoint("a", "b", "c", "d", "e", "f", "g", true, true, company.Id); var category = new CategoryInterestPoint("vegan"); ipbo.Create(interestPoint); cipbo.Create(category); var interestPointCategoryInterestPoint = new InterestPointCategoryInterestPoint(interestPoint.Id, category.Id); item.InterestPointId = interestPointCategoryInterestPoint.InterestPointId; item.CategoryId = interestPointCategoryInterestPoint.CategoryId; var resUpdate = ipcipbo.UpdateAsync(item).Result; resList = ipcipbo.ListAsync().Result; Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().InterestPointId == interestPoint.Id && resList.Result.First().CategoryId == category.Id); }
public static void Seed() { using var _ctx = new BoraNowContext(); _ctx.Database.EnsureDeleted(); _ctx.Database.EnsureCreated(); var categoryOne = new CategoryInterestPoint("VeganFood"); var categoryTwo = new CategoryInterestPoint("SeaFood"); var categoryThree = new CategoryInterestPoint("AsianFood"); var quiz = new Quiz("BoraNow quiz"); var quizQuestion = new QuizQuestion("What type of food are you looking for?", quiz.Id); var quizAnswerOne = new QuizAnswer("Vegan", quizQuestion.Id); var quizAnswerTwo = new QuizAnswer("Sea food", quizQuestion.Id); var quizAnswerThree = new QuizAnswer("Asian style", quizQuestion.Id); var countryOne = new Country("Angola"); var countryTwo = new Country("Portugal"); var profileOne = new Profile("blogueira vegana que adora viajar e conhecer novos locais", "mefamousstar.jpg"); var profileTwo = new Profile("Business Man with a chain of restauarants across Lisbon", "merichstar.jpg"); var company = new Company("PearTree Company", "Marco Pereria", "919200000", "23453554", profileTwo.Id); var visitor = new Visitor("Bruna", "Costa", DateTime.Now.AddYears(-24), "Female", profileOne.Id, countryOne.Id); var interestPoint = new InterestPoint("PearTree Abc", "very chill place that offers lots off tradicional food", "abc street", "uhuhuu.jpg", "3 am", "5 pm", "fridays", true, true, company.Id); var interestPointCategory = new InterestPointCategoryInterestPoint(interestPoint.Id, categoryOne.Id); var result = new Result("questionário nº 1", DateTime.Now, quiz.Id, visitor.Id); var resultInterestPoint = new ResultInterestPoint(result.Id, interestPoint.Id); var newsletter = new Newsletter("New place in town that has many vegan options", "Brand New"); var interestPointNewsletter = new InterestPointNewsletter(interestPoint.Id, newsletter.Id); var meteorology = new Meteorology(19, 27, 0, 1, 0, DateTime.Now.AddDays(1)); var feedback = new Feedback("very nice place, cousy vibes, really good food", 5, DateTime.Now.AddDays(-1), interestPoint.Id, visitor.Id); _ctx.Country.AddRange(countryOne); _ctx.Country.AddRange(countryTwo); _ctx.Profile.AddRange(profileOne); _ctx.Profile.AddRange(profileTwo); _ctx.Company.AddRange(company); _ctx.Visitor.AddRange(visitor); _ctx.Category.AddRange(categoryOne); _ctx.Category.AddRange(categoryTwo); _ctx.Category.AddRange(categoryThree); _ctx.Quiz.AddRange(quiz); _ctx.QuizQuestion.AddRange(quizQuestion); _ctx.QuizAnswer.AddRange(quizAnswerOne); _ctx.QuizAnswer.AddRange(quizAnswerTwo); _ctx.QuizAnswer.AddRange(quizAnswerThree); _ctx.InterestPoint.AddRange(interestPoint); _ctx.InterestPointCategory.AddRange(interestPointCategory); _ctx.Result.AddRange(result); _ctx.ResultInterestPoint.AddRange(resultInterestPoint); _ctx.Newsletter.AddRange(newsletter); _ctx.InterestPointNewsletter.AddRange(interestPointNewsletter); _ctx.Feedback.AddRange(feedback); _ctx.Meteorology.AddRange(meteorology); _ctx.SaveChanges(); }
public async Task DeleteAsync(CategoryInterestPoint category) { category.IsDeleted = true; await UpdateAsync(category); }
public void Delete(CategoryInterestPoint category) { category.IsDeleted = true; Update(category); }
public async Task UpdateAsync(CategoryInterestPoint category) { _context.Entry(category).State = EntityState.Modified; await _context.SaveChangesAsync(); }
public void Update(CategoryInterestPoint category) { _context.Entry(category).State = EntityState.Modified; _context.SaveChanges(); }
public async Task CreateAsync(CategoryInterestPoint category) { await _context.Category.AddAsync(category); await _context.SaveChangesAsync(); }
public void Create(CategoryInterestPoint category) { _context.Category.Add(category); _context.SaveChanges(); }
public bool CompareToModel(CategoryInterestPoint categoryInterestPoint) { return(Name == categoryInterestPoint.Name); }