コード例 #1
0
        public string DenyAppUser([FromBody] PomModelForAuthorization pom)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState).ToString());
            }

            AppUser current = _unitOfWork.AppUsers.Get(pom.Id);

            if (current.Image == "")
            {
                return("NotOk");
            }

            current.Activated = false;
            current.Deny      = true;

            _unitOfWork.AppUsers.Update(current);
            _unitOfWork.Complete();

            string passTypeName = _unitOfWork.PassangerTypes.Find(x => x.Id == current.PassangerTypeId).FirstOrDefault().Name;

            string subject         = "AppUser denied";
            string desc            = $"Dear {current.Name}, You have been denied as {passTypeName}.";
            var    controllerEmail = current.Email;

            NotifyViaEmail(controllerEmail, subject, desc);

            return("Ok");
        }
コード例 #2
0
        public string AuthorizeAdmin([FromBody] PomModelForAuthorization pomModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState).ToString());
            }
            //Get user data, and update activated to true
            //ApplicationUser current = UserManager.FindById(Id.Id);
            AppUser current = _unitOfWork.AppUsers.Get(pomModel.Id);

            current.Activated = true;


            _unitOfWork.AppUsers.Update(current);
            _unitOfWork.Complete();


            string subject    = "Admin approved";
            string desc       = $"Dear {current.Name}, You have been approved as admin.";
            var    adminEmail = current.Email;

            NotifyViaEmail(adminEmail, subject, desc);

            return("Ok");
        }
コード例 #3
0
        public string ValidateTicket(PomModelForAuthorization pomModel)
        {
            int idTicket = Int32.Parse(pomModel.Id);

            Ticket ticketFormDb = _unitOfWork.Tickets.Get(idTicket);

            if (ticketFormDb == null)
            {
                return("Ticket doesn't exist in db! ");
            }

            string nameOfTicket = _unitOfWork.TypeOfTickets.Get(Int32.Parse(ticketFormDb.TypeOfTicketId.ToString())).Name;//get TimeLimited, Daily, Monthly,Annul


            DateTime purchaseDateTime = DateTime.Parse(ticketFormDb.PurchaseDate.ToString());

            //int? v1;
            //int v2;
            //v2 = v1 == null ? default(int) : v1;

            if (ticketFormDb.AppUserId == null)
            {
                string s = CheckTicketWithoutUser(nameOfTicket, purchaseDateTime);
                return(s);
            }
            else
            {
                string ss = CheckTicket(nameOfTicket, purchaseDateTime);
                return(ss);
            }


            //return "Ok";
        }
コード例 #4
0
        public async Task <byte[]> GetUserImage(PomModelForAuthorization email)
        {
            //int userId = _unitOfWork.AppUserRepository.Find(u => u.Email == email).FirstOrDefault()
            AppUser uid = _unitOfWork.AppUsers.Find(u => u.Email == email.Id).FirstOrDefault();

            var filePath = HttpContext.Current.Server.MapPath(uid.Image);

            if (File.Exists(filePath))
            {
                byte[] bytes          = File.ReadAllBytes(filePath);
                byte[] decryptedBytes = DecryptBytes(bytes, "password", "asdasd");
                return(decryptedBytes);
            }

            return(null);
        }
コード例 #5
0
        public PomModelForAuthorization Calculate(PomModelForPriceList pom)
        {
            PomModelForAuthorization p = new PomModelForAuthorization();

            PassangerType pass = _unitOfWork.PassangerTypes.Find(x => x.Name == pom.PassangerType).FirstOrDefault();

            int idTicket = _unitOfWork.TypeOfTickets.Find(x => x.Name == pom.TypeOfTicket).FirstOrDefault().Id;

            double regularPriceTicket = _unitOfWork.TicketPrices.Find(x => (x.PriceListId == pom.PriceListId && x.TypeOfTicketId == idTicket)).FirstOrDefault().Price;

            double finallyPrice = regularPriceTicket - (regularPriceTicket * pass.RoleCoefficient);

            p.Id = finallyPrice.ToString();

            return(p);
        }
コード例 #6
0
        public string AuthorizeDeniedUser([FromBody] PomModelForAuthorization pomModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState).ToString());
            }
            //Get user data, and update activated to true
            //ApplicationUser current = UserManager.FindById(Id.Id);
            AppUser current = _unitOfWork.AppUsers.Get(pomModel.Id);

            current.Activated = true;
            current.Deny      = false;

            string userTypee = _unitOfWork.UserTypes.Find(a => a.Id == current.UserTypeId).FirstOrDefault().Name;
            string passType  = "";

            if (userTypee == "AppUser")
            {
                passType = _unitOfWork.PassangerTypes.Find(a => a.Id == current.PassangerTypeId).FirstOrDefault().Name;
            }



            _unitOfWork.AppUsers.Update(current);
            _unitOfWork.Complete();


            //string subject = $"{(userTypee == "AppUser") ? passType : userTypee} approved";
            string subject = (userTypee == "AppUser") ? passType : userTypee + " approved";
            string desc    = $"Dear {current.Name}, You have been approved as ";

            desc += (userTypee == "AppUser") ? passType : userTypee + ".";
            var adminEmail = current.Email;

            NotifyViaEmail(adminEmail, subject, desc);

            return("Ok");
        }
コード例 #7
0
        public string DenyControll([FromBody] PomModelForAuthorization pom)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState).ToString());
            }
            //Get user data, and update activated to true
            //ApplicationUser current = UserManager.FindById(pom.Id);

            AppUser current = _unitOfWork.AppUsers.Get(pom.Id);

            current.Activated = false;
            current.Deny      = true;
            _unitOfWork.AppUsers.Update(current);
            _unitOfWork.Complete();

            string subject         = "Controller denied";
            string desc            = $"Dear {current.Name}, You have been denied as controller.";
            var    controllerEmail = current.Email;

            NotifyViaEmail(controllerEmail, subject, desc);

            return("Ok");
        }