public IActionResult Register([Bind] UserProfileDto user) { BillingSystemContext context = new BillingSystemContext(); var registeredUserName = context.Users.Where(u => u.UserName.Equals(user.UserName)).SingleOrDefault(); if (registeredUserName != null) { ViewBag.Error = "This user is already registered."; return(View()); } if (context.Users.Any(u => u.Email == user.Email)) { ViewBag.Error = "This e-mail is already taken."; return(View()); } try { UsersBLL bll = new UsersBLL(); bll.RegisterUser(user); return(RedirectToAction("UserLogin", "Login")); } catch (Exception ex) { } return(View()); }
public ActionResult UserLogin([Bind] Users user) { BillingSystemContext context = new BillingSystemContext(); Users userFromBase = context.Users.FirstOrDefault(u => u.UserName == user.UserName); if (userFromBase != null && SecurePasswordHasher.Verify(user.Password, userFromBase.Password)) { UsersBLL usersBLL = new UsersBLL(); UserClaimsDto userRoles = usersBLL.GetUserClaims(user.UserName); var userClaims = new List <Claim>() { new Claim(ClaimTypes.Name, userRoles.UserName), new Claim(ClaimTypes.Email, userRoles.Email) }; foreach (RoleMaster rm in userRoles.Roles) { userClaims.Add(new Claim(ClaimTypes.Role, rm.RollName)); } var grandmaIdentity = new ClaimsIdentity(userClaims, "User Identity"); var userPrincipal = new ClaimsPrincipal(new[] { grandmaIdentity }); HttpContext.SignInAsync(userPrincipal); return(RedirectToAction("Index", "Home")); } return(View(user)); }
private List <ClientStatusDTO> FilterByComment(string Comment) { BillingSystemContext context = new BillingSystemContext(); List <Client> clients = context.Clients.Include(c => c.ClientZone).Include(c => c.ClientTarif) .Where(c => c.Comment.ToLower() .Contains(Comment.ToLower())).ToList(); List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>(); foreach (Client c in clients) { ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c); if (newClient.Validity >= DateTime.Now) { newClient.Status = "ACTIVE"; } else { newClient.Status = "INACTIVE"; } clientsDTO.Add(newClient); } return(clientsDTO); }
public List <ClientStatusDTO> GetInActiveClients() { BillingSystemContext context = new BillingSystemContext(); context.Clients.Where(c => c.Validity < DateTime.Now).ToList(); List <Client> clients = context .Clients.Include(c => c.ClientTarif) .Include(c => c.ClientZone) .ToList(); List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>(); foreach (Client c in clients) { ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c); if (newClient.Validity >= DateTime.Now) { newClient.Status = "ACTIVE"; } else { newClient.Status = "INACTIVE"; } clientsDTO.Add(newClient); } return(clientsDTO); }
public void Add( string ClientName, string Address, string PhoneNumber, string Tariff, string Zone, string PonClient, string Comment) { BillingSystemContext context = new BillingSystemContext(); int zone = context.Zones.FirstOrDefault(z => z.Town == Zone).IDNumber; int tariff = context.Tariffs.FirstOrDefault(t => t.Name == Tariff).IDNumber; Client client = new Client() { Name = ClientName, Adress = Address, ZoneId = zone, IPAdress = null, PhoneNumber = PhoneNumber, Comment = Comment, Included = DateTime.Now, Validity = DateTime.Now, TariffId = tariff }; ClientsDao dao = new ClientsDao(); dao.Insert(client); }
public void DeleteClient(int IDNumber) { BillingSystemContext context = new BillingSystemContext(); Client client = context.Clients.FirstOrDefault(c => c.IDNumber == IDNumber); ClientsDao dao = new ClientsDao(); dao.Delete(client); }
public void DeleteTariff(int id) { BillingSystemContext context = new BillingSystemContext(); Tariff tariff = context.Tariffs.FirstOrDefault(t => t.IDNumber == id); TariffDao tariffDao = new TariffDao(); tariffDao.Delete(tariff); }
public void DeleteProfile(int id) { BillingSystemContext context = new BillingSystemContext(); Profile profile = context.Profiles.FirstOrDefault(p => p.IDNumber == id); ProfileDAO dao = new ProfileDAO(); dao.Delete(profile); }
public void DeleteZone(int id) { BillingSystemContext context = new BillingSystemContext(); Zone zone = context.Zones.FirstOrDefault(z => z.IDNumber == id); ZoneDao dao = new ZoneDao(); dao.Delete(zone); }
public ClientStatusDTO GetClient(int ID) { BillingSystemContext context = new BillingSystemContext(); Client client = context.Clients .Include(c => c.ClientTarif) .Include(c => c.ClientZone) .FirstOrDefault(c => c.IDNumber == ID); ClientStatusDTO clientDto = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(client); return(clientDto); }
public UserClaimsDto GetUserClaims(string username) { UserClaimsDto userdto = new UserClaimsDto(); BillingSystemContext context = new BillingSystemContext(); Users user = context.Users.FirstOrDefault(u => u.UserName == username); userdto.UserName = user.UserName; userdto.Email = user.Email; userdto.Roles = context.RoleMasters .Where(r => context.UserRoleMappings .Any(urm => urm.RoleID == r.IDNumber && urm.UserID == user.IDNumber)).ToList(); return(userdto); }
public void Add( string Town, string Owner) { BillingSystemContext context = new BillingSystemContext(); Zone zone = new Zone() { Town = Town, Owner = Owner }; ZoneDao dao = new ZoneDao(); dao.Insert(zone); }
public void Add( string PhoneNumber, string Name) { BillingSystemContext context = new BillingSystemContext(); Profile profile = new Profile() { PhoneNumber = PhoneNumber, Name = Name }; ProfileDAO dao = new ProfileDAO(); dao.Insert(profile); }
public void UpdateZone( string Town, string Owner, int IDNumber) { BillingSystemContext context = new BillingSystemContext(); Zone zone = new Zone() { Town = Town, Owner = Owner, IDNumber = IDNumber }; ZoneDao dao = new ZoneDao(); dao.Update(zone); }
public void Add( string Name, int Price, int InternetSpeed) { BillingSystemContext context = new BillingSystemContext(); Tariff tariff = new Tariff() { Name = Name, Price = Price, InternetSpeed = InternetSpeed }; TariffDao tariffDao = new TariffDao(); tariffDao.Insert(tariff); }
public void UpdateTariff( string Name, int Price, int InternetSpeed, int IDNumber) { BillingSystemContext context = new BillingSystemContext(); Tariff tariff = new Tariff() { Name = Name, Price = Price, InternetSpeed = InternetSpeed, IDNumber = IDNumber }; TariffDao tariffDao = new TariffDao(); tariffDao.Update(tariff); }
public void UpdateProfile( string PhoneNumber, string Name, int IDNumber) { BillingSystemContext context = new BillingSystemContext(); Profile profile = new Profile() { PhoneNumber = PhoneNumber, Name = Name, IDNumber = IDNumber }; ProfileDAO dao = new ProfileDAO(); dao.Update(profile); }
public IActionResult ProfileDetails() { ProfileBLL profileBLL = new ProfileBLL(); //string userName = this.User.Claims.FirstOrDefault(c => c.Type == "Name").Value; string userName = HttpContext.User.FindFirst(ClaimTypes.Name).Value; BillingSystemContext context = new BillingSystemContext(); Users currUser = context.Users.FirstOrDefault(u => u.UserName == userName); Profile prof = profileBLL.GetProfile(currUser.ProfileID); if (prof == null) { NotFound(); } return(View(prof)); }
public Payment RegisterPayment(int ClientId, decimal Amount) { try { using (BillingSystemContext context = new BillingSystemContext()) { DateTime validity = context.Clients.FirstOrDefault(c => c.IDNumber == ClientId).Validity; Tariff tarif = context.Clients .Include(c => c.ClientTarif) .FirstOrDefault(c => c.IDNumber == ClientId).ClientTarif; Tariff tarifa = context.Tariffs .FirstOrDefault( t => t.IDNumber == context.Clients.FirstOrDefault(c => c.TariffId == t.IDNumber).TariffId); decimal tarifPrice = tarifa.Price; decimal amount = Amount; int months = Convert.ToInt32(amount / tarifPrice); Payment payment = new Payment() { Client = ClientId, Date = DateTime.Now, Amount = Amount }; validity = validity.AddMonths(months); context.Payments.Add(payment); context.Clients.FirstOrDefault(c => c.IDNumber == payment.Client).Validity = validity; context.SaveChanges(); return(payment); } } catch (Exception) { throw; } }
public void RegisterUser(UserProfileDto profileDto) { Profile profile = new Profile(); profile.Name = profileDto.Name; profile.PhoneNumber = profileDto.PhoneNumber; BillingSystemContext context = new BillingSystemContext(); context.Profiles.Add(profile); context.SaveChanges(); Users user = new Users(); user.UserName = profileDto.UserName; user.Email = profileDto.Email; user.Password = SecurePasswordHasher.Hash(profileDto.Password); user.ConfirmPassword = SecurePasswordHasher.Hash(profileDto.ConfirmPassword); user.ProfileID = profile.IDNumber; context.Users.Add(user); context.SaveChanges(); }
public Profile GetProfile(string Name) { BillingSystemContext context = new BillingSystemContext(); return(context.Profiles.FirstOrDefault(p => p.Name == Name)); }
public List <ClientStatusDTO> GetFilteredClients(ClientFilterType FilterType, string Filter) { if (FilterType == ClientFilterType.Name) { BillingSystemContext context = new BillingSystemContext(); List <Client> clients = context .Clients.Include(c => c.ClientTarif) .Include(c => c.ClientZone) .ToList(); List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>(); foreach (Client c in clients) { ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c); if (newClient.Validity >= DateTime.Now) { newClient.Status = "ACTIVE"; } else { newClient.Status = "INACTIVE"; } clientsDTO.Add(newClient); } FilterByName(Filter); return(clientsDTO); } else if (FilterType == ClientFilterType.Address) { BillingSystemContext context = new BillingSystemContext(); List <Client> clients = context .Clients.Include(c => c.ClientTarif) .Include(c => c.ClientZone) .ToList(); List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>(); foreach (Client c in clients) { ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c); if (newClient.Validity >= DateTime.Now) { newClient.Status = "ACTIVE"; } else { newClient.Status = "INACTIVE"; } clientsDTO.Add(newClient); } FilterByAddress(Filter); return(clientsDTO); } else if (FilterType == ClientFilterType.PhoneNumber) { BillingSystemContext context = new BillingSystemContext(); List <Client> clients = context .Clients.Include(c => c.ClientTarif) .Include(c => c.ClientZone) .ToList(); List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>(); foreach (Client c in clients) { ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c); if (newClient.Validity >= DateTime.Now) { newClient.Status = "ACTIVE"; } else { newClient.Status = "INACTIVE"; } clientsDTO.Add(newClient); } FilterByPhoneNumber(Filter); return(clientsDTO); } else if (FilterType == ClientFilterType.IPAdress) { BillingSystemContext context = new BillingSystemContext(); List <Client> clients = context .Clients.Include(c => c.ClientTarif) .Include(c => c.ClientZone) .ToList(); List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>(); foreach (Client c in clients) { ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c); if (newClient.Validity >= DateTime.Now) { newClient.Status = "ACTIVE"; } else { newClient.Status = "INACTIVE"; } clientsDTO.Add(newClient); } FilterByIPAdress(Filter); return(clientsDTO); } else if (FilterType == ClientFilterType.comment) { BillingSystemContext context = new BillingSystemContext(); List <Client> clients = context .Clients.Include(c => c.ClientTarif) .Include(c => c.ClientZone) .ToList(); List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>(); foreach (Client c in clients) { ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c); if (newClient.Validity >= DateTime.Now) { newClient.Status = "ACTIVE"; } else { newClient.Status = "INACTIVE"; } clientsDTO.Add(newClient); } FilterByComment(Filter); return(clientsDTO); } throw new InvalidEnumArgumentException("No such filter type."); }
public List <Client> GetExpiringClients() { BillingSystemContext context = new BillingSystemContext(); return(context.Clients.Where(c => c.Validity > DateTime.Now.AddDays(-5) && c.Validity <= DateTime.Now).ToList()); }
public List <Client> GetClientsByTariff(string FilterTariff) { BillingSystemContext context = new BillingSystemContext(); return(context.Clients.Include(c => c.TariffId).Where(c => c.ClientTarif.Name == FilterTariff).ToList()); }
public Zone GetZone(string Name) { BillingSystemContext context = new BillingSystemContext(); return(context.Zones.FirstOrDefault(z => z.Town == Name)); }
public List <Payment> GetPaymetsTimeSpan(DateTime From, DateTime To) { BillingSystemContext context = new BillingSystemContext(); return(context.Payments.Where(p => p.Date >= From && p.Date <= To).ToList()); }
public List <Users> GetUsers() { BillingSystemContext context = new BillingSystemContext(); return(context.Users.ToList()); }
public bool HasExpiredClients() { BillingSystemContext context = new BillingSystemContext(); return(context.Clients.Any(c => c.Validity > DateTime.Now)); }
public List <Client> GetClientsByZone(string Zone) { BillingSystemContext context = new BillingSystemContext(); return(context.Clients.Include(c => c.Name).Where(c => c.ClientZone.Town == Zone).ToList()); }
public List <Client> GetClientsByZoneID(int ZoneId) { BillingSystemContext context = new BillingSystemContext(); return(context.Clients.Include(c => c.IDNumber).Where(c => c.ClientZone.IDNumber == ZoneId).ToList()); }