public void CreateExercise([FromForm] Exercise model) { _db.Exercise.CreateExercise(model); _db.Save(); }
public void Create(Book book) { _repo.Book.Create(book); _repo.Save(); }
public void Create(Nivel nivel) { _repo.Nivel.Create(nivel); _repo.Save(); }
public void Post([FromBody] Product value) { _repoWrapper.Product.Add(value); _repoWrapper.Save(); }
public Alert SaveAlert(Alert a) { repository.Alert.Create(a); repository.Save(); return(a); }
public void Create(CourseMaterial courseMaterial) { _repo.CourseMaterial.Create(courseMaterial); _repo.Save(); }
public void Create(CourseAttendance courseAttendance) { _repo.CourseAttendance.Create(courseAttendance); _repo.Save(); }
//lista FK-urilor /*public List<Subscription> GetAllSubbs() * { * return _repo.Subscription.FindAll(); * }*/ public void Create(Subscription subscription) { _repo.Subscription.Create(subscription); _repo.Save(); }
public void Post([FromBody] Topping value) { _repoWrapper.Topping.Add(value); _repoWrapper.Save(); }
public void Create(Secretary secretary) { _repo.Secretary.Create(secretary); _repo.Save(); }
public IActionResult Post([FromBody] Species value) { _repoWrapper.Species.AddSpecies(value); _repoWrapper.Save(); return(Ok()); }
public ActionResult Charge(string stripeEmail, string stripeToken, int accountId) { try { var customers = new CustomerService(); var charges = new ChargeService(); var account = _repo.Account.FindByCondition(a => a.Id == accountId).FirstOrDefault(); var customer = customers.Create(new CustomerCreateOptions { Email = stripeEmail, Source = stripeToken }); var charge = charges.Create(new ChargeCreateOptions { Amount = (long)account.Balance,//charge in cents Description = "Sample Charge", Currency = "usd", Customer = customer.Id }); account.Balance = 0; _repo.Account.Update(account); _repo.Save(); return(View("BalanceDetails", account)); } catch (Exception) { return(View("Index")); } }
public void CreateBooking(Booking booking) { _repository.Booking.CreateBooking(booking); _repository.Save(); }
public void Create(Student student) { _repo.Student.Create(student); _repo.Save(); }
public async Task <IActionResult> Create(DinerCuisineVM VM) { if (ModelState.IsValid) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); VM.Diner.IdentityUserId = userId; _repo.Diner.CreateDiner(VM.Diner); await _repo.Save(); await UpdatePreferences(VM.Cuisines, VM.Diner); return(RedirectToAction("index")); } return(View());//VM.Diner); }
public void Save() { _repoWrapper.Save(); }
public void Post([FromBody] Student student) { _repo.Student.Create(student); _repo.Save(); }
public void AddEmployee(Employee employee) { repositoryWrapper.Employee.Create(employee); repositoryWrapper.Save(); }
public ActionResult <ParticipationDto> CreateInvitation(Guid personId, Guid projectId, [FromBody] CreateInvitationDto dto) { try { if (!ModelState.IsValid) { return(BadRequest()); } if (!_db.Person.BelongsToUser(personId, HttpContext)) { return(Forbid()); } if (_db.Participation.GetRole(personId, projectId)?.ParticipantsWrite != true) { return(Forbid()); } var person = _db.Person.FindByCondition(x => x.Id == dto.PersonId).SingleOrDefault(); if (person == null) { return(BadRequest(nameof(PersonNotFoundException))); } var role = _db.Role.FindByCondition(x => x.Id == dto.RoleId && x.ProjectId == projectId).SingleOrDefault(); if (role == null) { return(BadRequest()); } var participation = _mapper.Map <Participation>(dto); participation.ProjectId = projectId; participation.Status = ParticipationStatus.Invited.ToString(); _db.Participation.Create(participation); _db.Save(); var insertedParticipation = _db.Participation .FindByCondition(x => x.Id == participation.Id) .Include(x => x.Person) .Include(x => x.Role) .SingleOrDefault(); return(Ok(_mapper.Map <ParticipationDto>(insertedParticipation))); } catch (Exception e) { _logger.LogError($"ERROR in CreateInvitation: {e.Message}"); return(StatusCode(500, "Internal server error")); } }
public ActionResult EditProfile(RoboDexer roboDexer) { _repo.RoboDexer.Update(roboDexer); _repo.Save(); return(RedirectToAction("Index")); }
public void Delete(long id) { _repoWrapper.Word.Delete(_repoWrapper.Word.FindByCondition(w => w.Id.Equals(id)).FirstOrDefault()); _repoWrapper.Save(); }
public void CreateHotel(Hotel hotel) { _repository.Hotel.CreateHotel(hotel); _repository.Save(); }
public async Task <IActionResult> RegisterForAdminPage([FromBody] UserForRegistrationDto userForRegistration) { if (userForRegistration == null || !ModelState.IsValid) { return(BadRequest()); } var user = _mapper.Map <ApplicationUser>(userForRegistration); //Nếu validate có lỗi thì trả về bad request var validate = _repository.Authenticate.ValidateRegistration(userForRegistration); if (validate != null) { return(BadRequest(validate)); } var userFinding = await _userManager.FindByEmailAsync(userForRegistration.Email); if (userFinding != null) { return(BadRequest(new AuthResponseDto { Message = "Email này đã tồn tại. Vui lòng nhập email khác!" })); } var result = await _userManager.CreateAsync(user, userForRegistration.Password); if (!result.Succeeded) { var errors = result.Errors.Select(e => e.Description); return(BadRequest(new RegistrationResponseDto { Errors = errors })); } var roleExist = await _roleManager.RoleExistsAsync("Editor"); if (!roleExist) { await _roleManager.CreateAsync(new IdentityRole("Editor")); } await _userManager.AddToRoleAsync(user, "Editor"); await _userManager.SetLockoutEnabledAsync(user, true);//Lockout account để đợi admin xét duyệt xong mới mở ra var response = _repository.User.CreateUser( new User() { Quyen = userForRegistration.Quyen, UserName = user.LastName + " " + user.FirstName, ApplicationUserID = user.Id }); if (response != null) { _repository.Save(); } else { _logger.LogError($"Lỗi khi đăng ký user cho trang admin với email {userForRegistration.Email}"); } return(Ok(new AuthResponseDto { Message = "Tài khoản đã được tạo!" })); }
public IActionResult CreateUpdate(FeedUpdate update) { FeedUpdate newUpdate = new FeedUpdate(); DateTime dt = DateTime.Now; string timeStamp = dt.ToShortDateString(); newUpdate.Description = update.Description; newUpdate.PubDate = timeStamp; newUpdate.PetBusinessId = update.PetBusinessId; newUpdate.BusinessName = update.BusinessName; _repo.FeedUpdate.Create(newUpdate); _repo.Save(); return(RedirectToAction(nameof(Index))); }
public IActionResult AddProduct([FromBody] object postData) { try { if (postData == null) { return(BadRequest()); } var data = JsonConvert.DeserializeObject <Product>(postData.ToString()); var found = _repoWrapper.Product.FindByCondition(x => x.CategoryOid == data.CategoryOid && x.Name == data.Name); if (found.Any()) { ErrorApiModel eam = new ErrorApiModel() { Message = $"Item already exsist" }; return(BadRequest(eam)); } if (data.SelectedTags != null) { foreach (var tagId in data.SelectedTags) { data.ProductTags.Add(new ProductTag() { Oid = Guid.NewGuid(), TagOid = tagId, ProductOid = data.Oid, CreatedDate = DateTime.Now }); } } _repoWrapper.Product.Add(data); _repoWrapper.Save(); return(NoContent()); } catch (Exception ex) { _logger.LogError($"Something went wrong inside AddProduct action: {ex.InnerException?.Message ?? ex.Message}"); _logger.LogError($"Something went wrong inside AddProduct action: {ex.StackTrace}"); return(StatusCode(500, "Internal server error")); } }
public void Save() { repositoryWrapper.Save(); }
public Budget GetCheckAndCreateBudget(Budgeteer budgeteer) { if (!(_repo.Budgets.FindByCondition(b => b.BudgeteerId == budgeteer.BudgeteerId).Any())) { var newBudget = new Budget { BudgetStartDate = DateTime.Today, MonthId = DateTime.Now.Month, Year = DateTime.Now.Year, BudgeteerId = budgeteer.BudgeteerId }; _repo.Budgets.Create(newBudget); _repo.Save(); } //Grab their current budget to pass to View var budget = _repo.Budgets.GetBudgetByBudgeteerIdMonthAndYear(budgeteer.BudgeteerId, DateTime.Now.Month, DateTime.Now.Year); if (budget == null)//If budget is null, that means there is a budget in the database, but its not current, need to make a new one { //grabs the last months budget so that important details can be transferred over and saved money can be calculated var lastMonthBudget = _repo.Budgets.GetBudgetByBudgeteerIdMonthAndYear(budgeteer.BudgeteerId, DateTime.Now.Month - 1, DateTime.Now.Year); CalculateMoneySaved(lastMonthBudget, budgeteer); budget = new Budget { MonthlyIncome = lastMonthBudget.MonthlyIncome, MonthlyLimit = lastMonthBudget.MonthlyLimit, RandomExpenseLimit = lastMonthBudget.RandomExpenseLimit, MonthlyBillMoney = 0, MonthlyBudgetItemMoney = 0, MonthlyDebtItemMoney = 0, MonthlyGoalItemMoney = 0, MonthlyMoneySaved = 0, MonthlyRandomExpenseMoney = 0, MonthlyTotalMoney = 0, CoffeeCategorySpent = 0, DiningOutCategorySpent = 0, EntertainmentCategorySpent = 0, GasCategorySpent = 0, GroceriesCategorySpent = 0, CoffeeCategoryLimit = lastMonthBudget.CoffeeCategoryLimit, DiningOutCategoryLimit = lastMonthBudget.DiningOutCategoryLimit, EntertainmentCategoryLimit = lastMonthBudget.EntertainmentCategoryLimit, GasCategoryLimit = lastMonthBudget.GasCategoryLimit, GroceriesCategoryLimit = lastMonthBudget.GroceriesCategoryLimit, BudgetStartDate = DateTime.Today, MonthId = DateTime.Now.Month, Year = DateTime.Now.Year, BudgeteerId = budgeteer.BudgeteerId }; _repo.Budgets.Create(budget); _repo.Save(); } return(budget); }
public void Create(Transaction transaction) { _repo.Transaction.Create(transaction); _repo.Save(); }
public async Task <IActionResult> Create(PostsViewModel model, string userId) { var files = HttpContext.Request.Form.Files; var usedFileName = default(string); foreach (var Image in files) { if (Image != null && Image.Length > 0) { var file = Image; var uploads = Path.Combine(_hostingEnvironment.WebRootPath, "uploads\\img\\posts"); if (file.Length > 0) { var fileName = ContentDispositionHeaderValue.Parse (file.ContentDisposition).FileName.Trim('"'); System.Console.WriteLine(fileName); using (var fileStream = new FileStream(Path.Combine(uploads, file.FileName), FileMode.Create)) { await file.CopyToAsync(fileStream); usedFileName = file.FileName; } } } } var post = new Post { Title = model.Title, Body = model.Body, CreationDate = DateTime.Now, CreatedBy = this.User.Identity.Name, Enabled = true, PostImage = usedFileName, UserId = userId, }; var listTagsId = new List <int>(); foreach (var tagItem in model.Tags) { tagItem.CreatedBy = User.Identity.Name; if (tagItem.IsSelected) { listTagsId.Add(tagItem.TagId); } } if (ModelState.IsValid) { _repositoryWrapper.Post.Create(post); var thisPost = post; _repositoryWrapper.Save(); foreach (var element in listTagsId) { var postTags = new PostTag { PostId = thisPost.PostId, TagId = element, }; _repositoryWrapper.PostTags.Create(postTags); _repositoryWrapper.Save(); } return(RedirectToAction(nameof(Index), new { userId = post.UserId })); } return(View(model)); }
public IActionResult Update(Restaurant restaurant, int id) //pass in ID of restaurant { repository.Restaurant.Update(restaurant); repository.Save(); //saves the updated changes return(RedirectToAction("Index")); //will return page to the index }