예제 #1
0
 //[HttpGet]
 public bool CheckValidity(ModelHelpTicketValidation tic)
 {
     if (tic.Name == null || tic.Name == "")
     {
         if (tic.Id == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         ApplicationUser a = UserManager.FindByEmail(tic.Name);
         if (a != null)
         {
             if (a.Activated != "ACTIVATED")
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(false);
         }
     }
 }
예제 #2
0
        public ValidateTicketHelpModel ValidateTicket(ModelHelpTicketValidation tic)
        {
            if (tic.Name == "" || tic.Name == null)
            {
                return(new ValidateTicketHelpModel(false, "You have to fill email address!"));
            }
            Ticket t = unitOfWork.Tickets.GetTicketWithInclude(tic.Id);

            if (t == null)
            {
                return(new ValidateTicketHelpModel(false, "There is not ticket with id: " + tic.Id + "!"));
            }



            if (tic.Name != t.ApplicationUser.Email)
            {
                string s = "User with email: " + tic.Name + " did not buy ticket with Id: " + tic.Id;
                return(new ValidateTicketHelpModel(false, s));
            }
            else
            {
                DateTime pr = (DateTime)t.PurchaseTime;
                DateTime dt = DateTime.Now;
                if (t.TicketTypeId == 1)
                {
                    DateTime aa = pr.AddHours(1);
                    if (aa < DateTime.Now)
                    {
                        return(new ValidateTicketHelpModel(false, "Ticket with id " + tic.Id + " is not valid. Time is up!"));
                    }
                    else
                    {
                        return(new ValidateTicketHelpModel(true, "Ticket with id " + tic.Id + " is valid!"));
                    }
                }
                if (t.TicketTypeId == 2)
                {
                    if (pr.Year < dt.Year)
                    {
                        return(new ValidateTicketHelpModel(false, "Ticket with id " + tic.Id + " is not valid. Time is up!"));
                    }
                    else if (pr.Year == dt.Year)
                    {
                        if (pr.Month < dt.Month)
                        {
                            return(new ValidateTicketHelpModel(false, "Ticket with id " + tic.Id + " is not valid. Time is up!"));
                        }
                        else if (pr.Month == dt.Month)
                        {
                            if (pr.Day == dt.Day)
                            {
                                return(new ValidateTicketHelpModel(true, "Ticket with id " + tic.Id + " is valid!"));
                            }
                            else
                            {
                                return(new ValidateTicketHelpModel(false, "Ticket with id " + tic.Id + " is not valid. Time is up!"));
                            }
                        }
                    }
                }

                if (t.TicketTypeId == 3)
                {
                    if (pr.Year < dt.Year)
                    {
                        return(new ValidateTicketHelpModel(false, "Ticket with id " + tic.Id + " is not valid. Time is up!"));
                    }
                    else if (pr.Year == dt.Year)
                    {
                        if (pr.Month == dt.Month)
                        {
                            return(new ValidateTicketHelpModel(true, "Ticket with id " + tic.Id + " is valid!"));
                        }
                        else
                        {
                            return(new ValidateTicketHelpModel(false, "Ticket with id " + tic.Id + " is not valid. Time is up!"));
                        }
                    }
                }

                if (t.TicketTypeId == 4)
                {
                    if (pr.Year == dt.Year)
                    {
                        return(new ValidateTicketHelpModel(true, "Ticket with id " + tic.Id + " is valid!"));
                    }
                    else
                    {
                        return(new ValidateTicketHelpModel(false, "Ticket with id " + tic.Id + " is not valid. Time is up!"));
                    }
                }

                return(new ValidateTicketHelpModel(true, "Ticket with id " + tic.Id + " is valid!"));
            }
        }