public bool CreateNewPizza(PizzaVM pizzaVM) { if (pizzaVM.Size == PizzaSize.Medium) { pizzaVM.Price = pizzaVM.Price; } if (pizzaVM.Size == PizzaSize.Small) { pizzaVM.Price *= 0.75; } if (pizzaVM.Size == PizzaSize.Family) { pizzaVM.Price *= 1.5; } var domainPizza = MapperToDM.MapPizzaVMToPizza(pizzaVM); var responce = _pizzaRepo.Create(domainPizza); if (responce) { return(true); } return(false); }
public bool Register(UserVM userVM) { var usersDomain = _userRepo.GetAll(); if (userVM.Email[0] >= 'a' && userVM.Email[0] <= 'z' && userVM.Email[userVM.Email.Length - 1] >= 'a' && userVM.Email[userVM.Email.Length - 1] <= 'z' && userVM.Email.Contains("@") && userVM.Email.Contains(".")) { if (userVM.Password[0] >= 'A' && userVM.Password[0] <= 'Z' && userVM.Password.Contains("$") && userVM.Password.Any(char.IsDigit)) { var user = MapperToDM.MapUserVMToUser(userVM); var existingEmailOrPass = usersDomain.SingleOrDefault(u => u.Email == user.Email || u.Password == user.Password); if (existingEmailOrPass != null) { return(false); } user.Id = usersDomain.Count + 1; _userRepo.Create(user); return(true); } else { return(false); } } else { return(false); } }
public bool DeleteStore(StoreVM storeVM) { var storeDomain = MapperToDM.MapStoreVMToStore(storeVM); var store = _storeRepo.GetAll().SingleOrDefault(x => x.Id == storeDomain.Id); if (store == null) { return(false); } _storeRepo.GetAll().Remove(store); return(true); }
public bool CreateNewStore(StoreVM storeVM) { var storeDomain = MapperToDM.MapStoreVMToStore(storeVM); var store = _storeRepo.GetAll().SingleOrDefault(x => x.Id == storeDomain.Id); if (store == null) { _storeRepo.GetAll().Add(store); return(true); } return(false); }
public bool DeletePizza(PizzaVM pizzaVM) { var domainPizza = MapperToDM.MapPizzaVMToPizza(pizzaVM); var newPizza = _pizzaRepo.GetAll().SingleOrDefault(x => x.Id == domainPizza.Id); if (newPizza == null) { return(false); } _pizzaRepo.GetAll().Remove(newPizza); return(true); }
public bool UpdateStore(StoreVM storeVM) { var storeDomain = MapperToDM.MapStoreVMToStore(storeVM); var store = _storeRepo.GetAll().SingleOrDefault(x => x.Id == storeDomain.Id); if (store == null) { return(false); } int index = _storeRepo.GetAll().IndexOf(store); _storeRepo.GetAll()[index] = storeDomain; return(true); }
public bool UpdatePizza(PizzaVM pizzaVM) { Pizza pizzaDomain = MapperToDM.MapPizzaVMToPizza(pizzaVM); Pizza pizza = _pizzaRepo.GetAll().SingleOrDefault(x => x.Id == pizzaDomain.Id); if (pizza == null) { return(false); } int index = _pizzaRepo.GetAll().IndexOf(pizza); _pizzaRepo.GetAll()[index] = pizzaDomain; return(true); }
public UserVM Login(UserVM user) { var userDomain = MapperToDM.MapUserVMToUser(user); var listOfUsers = _userRepo.GetAll(); var loggedUser = listOfUsers.SingleOrDefault(u => u.Email == userDomain.Email && u.Password == userDomain.Password); if (loggedUser == null) { return(null); } var returnUser = MapperToVM.MapUserToUserVM(loggedUser); return(returnUser); }