public ResponseVM CreateOrder(OrderVM model, string email) { bool res = false; if (email != null) { _orderRepository.Create(new Order { StartDateTime = model.StartDateTime, EndDateTime = model.EndDateTime, OrderUserName = email, OrderTimeNow = DateTime.Now, AccountId = model.AccountId }); _commitProvider.Save(); return(new ResponseVM() { Result = true, Message = "Pet Createed" }); } else { return(new ResponseVM() { Result = res, Message = "Account not Found!" }); } }
public async Task <ResponseVM> CreatePet(PetVM model, string email) { bool res = false; var account = await _accountRepository.FindByNameAccount(email); if (account != null) { _petRepository.Create(new Pet { PetName = model.PetName, PetAge = model.PetAge, PetSex = model.PetSex, PetWeight = model.PetWeight, AccountId = account.Id }); _commitProvider.Save(); return(new ResponseVM() { Result = true, Message = "Pet Createed" }); } else { return(new ResponseVM() { Result = res, Message = "Account not Found!" }); } }
public ResponseVM CreateComment(CommentVM model, string email) { bool res = false; if (email != null) { _commentRepository.Create(new Comment { Title = model.Title, Content = model.Message, AccounEmail = email, CommentTime = DateTime.Now, AccountId = model.AccountId }); _commitProvider.Save(); return(new ResponseVM() { Result = true, Message = "Pet Createed" }); } else { return(new ResponseVM() { Result = res, Message = "Account not Found!" }); } }
public IActionResult Delete(int?id) { if (id != null) { _bikeService.DeleteById(id); _commitProvider.Save(); return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
public async Task <ActionResult> Delete(string userId) { var account = await _userManagerService.GetUserById(userId); if (account != null) { IdentityResult result = await _userManagerService.DeleteAccount(account); _commitProvider.Save(); } return(RedirectToAction("UserList")); }
public void Create(string model, string userId, string providerId, string currentUserName) { //var res = _userManagerService.GetUserById(userId); _commentRepository.Create(new Comment { Content = model, OrderPlaced = DateTime.Now, AccountId = providerId, Name = currentUserName, UserId = userId }); _commitProvider.Save(); }
public void CreateBike(BikeViewModel model, string userId, byte[] imageData) { var res = _userManagerService.GetUserById(userId); _bikeRepository.Create(new Bike { Name = model.Name, MaxSpeed = model.MaxSpeed, TypeEngine = model.TypeEngine, Power = model.Power, Fuel = model.Fuel, Description = model.Description, AccountId = res.Result.Id, Price = model.Price, BikeImg = imageData }); _commitProvider.Save(); }
public void CreateTrip(TripViewModel model, string userId, byte[] imageData) { var res = _userManagerService.GetUserById(userId); _tripRepository.Create(new Trip { TripName = model.TripName, Type = model.Type, Distance = model.Distance, AmountOfPeople = model.AmountOfPeople, StartDate = model.StartDate, EndTrip = model.EndTrip, Description = model.Description, AccountId = res.Result.Id, Price = model.Price, TripImg = imageData }); _commitProvider.Save(); }
public async Task <IActionResult> Edit(EditAccountUserViewModel model) { if (ModelState.IsValid) { var account = await _userManagerService.GetUserById(model.Id); if (account != null) { if (model.AccountImg != null) { byte[] imageData = null; using (var binaryReader = new BinaryReader(model.AccountImg.OpenReadStream())) { imageData = binaryReader.ReadBytes((int)model.AccountImg.Length); } account.Name = model.Name; account.PhoneNumber = model.PhoneNumber; account.Adress = model.Adress; account.Description = model.Description; account.AccountImg = imageData; var result = await _userManagerService.UpdateAccount(account); if (result.Succeeded) { _commitProvider.Save(); return(RedirectToAction("Index")); } else { foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } } } } return(View(model)); }