public void Test_releaseslotRepo()
        {
            int Resdb;

            Hpr = new HolderPersonRepository();
            int                 res         = Hpr.releaseslot(Hp);
            HolderDetail        holder      = new HolderDetail();
            List <HolderDetail> list        = new List <HolderDetail>();
            DateTime            thisDay     = DateTime.Today;
            var                 dateAndTime = DateTime.Now;
            var                 date        = dateAndTime.Date;

            using (SMPSEntities123 objectContext = new SMPSEntities123())
            {
                list = objectContext.HolderDetails.Where <HolderDetail>(h => h.EmpNo == Hp.EmpNo && h.SlotReleasedDate == date).ToList();
                if (list.Count <= 0)
                {
                    var affectedRows = objectContext.Database.ExecuteSqlCommand("holderdatainsertion @EmpNo={0},@ParkingSlotNumber={1},@CreatedDate={2},@SlotReleasedDate={3},@AllocationType={4},@OperationType={5}", Hp.EmpNo, Hp.ParkingSlotNumber, date, date, 0, 1);
                    Resdb = affectedRows = true ? 1 : 0;
                }
                else
                {
                    Resdb = 0;
                }
            }
            Assert.AreEqual(res.GetType(), Resdb.GetType());
        }
 public int releaseslot(HolderPerson HLD)
 {
     try
     {
         HolderDetail        holder  = new HolderDetail();
         List <HolderDetail> list    = new List <HolderDetail>();
         DateTime            thisDay = DateTime.Today;
         var dateAndTime             = DateTime.Now;
         var date = dateAndTime.Date;
         using (SMPSEntities123 objectContext = new SMPSEntities123())
         {
             list = objectContext.HolderDetails.Where <HolderDetail>(h => h.EmpNo == HLD.EmpNo && h.SlotReleasedDate == date).ToList();
             if (list.Count <= 0)
             {
                 var affectedRows = objectContext.Database.ExecuteSqlCommand("holderdatainsertion @EmpNo={0},@ParkingSlotNumber={1},@CreatedDate={2},@SlotReleasedDate={3},@AllocationType={4},@OperationType={5}", HLD.EmpNo, HLD.ParkingSlotNumber, date, date, 0, 1);
                 return(affectedRows = true ? 1 : 0);
             }
             else
             {
                 return(0);
             }
         }
     }catch (Exception ex)
     {
         throw ex;
     }
 }
        public string RequestForSlot(int EmpNo)
        {
            string Seekeroutputmessage;

            int                 PSN;
            int                 output;
            HolderDetail        holder = new HolderDetail();
            List <HolderDetail> Hlist  = new List <HolderDetail>();
            SeekerDetail        seeker = new SeekerDetail();
            User                usr;
            User                HolderUser;
            List <SeekerDetail> skr;

            seeker.EmpNo       = EmpNo;
            seeker.CreatedDate = DateTime.Now;
            List <User> list        = new List <User>();
            DateTime    thisDay     = DateTime.Now;
            var         dateAndTime = DateTime.Now;
            var         date        = dateAndTime.Date;

            var SeekerdateAndTime = DateTime.Now;
            var Seekerdate        = dateAndTime.Date;


            try
            {
                SMPSEntities123 objectContext = new SMPSEntities123();


                Hlist = objectContext.HolderDetails.Where <HolderDetail>(h => h.OperationType == 1 && h.CreatedDate == date).ToList();
                usr   = objectContext.Users.Where <User>(u => u.EmpNo == EmpNo).SingleOrDefault();

                seeker.EmpNo = usr.EmpNo;
                string   currentdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                DateTime dt          = DateTime.ParseExact(currentdate, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
                seeker.CreatedDate = dt;

                if (Hlist.Count() > 0)
                {
                    skr = objectContext.SeekerDetails.Where(s => s.EmpNo == seeker.EmpNo && s.CreatedDate.Year == seeker.CreatedDate.Year && s.CreatedDate.Month == seeker.CreatedDate.Month && s.CreatedDate.Day == seeker.CreatedDate.Day).ToList();
                    if (skr == null)
                    {
                        int empno = (int)Hlist[0].EmpNo;
                        //holder updation allocation and operation type
                        var affectedRows = objectContext.Database.ExecuteSqlCommand("UpadtingOperationandallocation @EmpNo={0},@CreatedDate={1}", Hlist[0].EmpNo, Hlist[0].CreatedDate);
                        HolderUser = objectContext.Users.Where <User>(u => u.EmpNo == empno).SingleOrDefault();
                        PSN        = Convert.ToInt32(HolderUser.ParkingSlotNumber);
                        //check once working r not



                        var          Res = objectContext.Database.ExecuteSqlCommand("sp_seekerdetails @EmpNo={0}, @ParkingSlotNumber={1},@CreatedDate={2},@SlotReleasedDate={3}, @AllocationType={4},@OperationType={5}", seeker.EmpNo, PSN, seeker.CreatedDate, seeker.CreatedDate, 1, 0);
                        SeekerDetail SL  = objectContext.SeekerDetails.Where(s => s.EmpNo == seeker.EmpNo && s.CreatedDate.Year == seeker.CreatedDate.Year && s.CreatedDate.Month == seeker.CreatedDate.Month && s.CreatedDate.Day == seeker.CreatedDate.Day).SingleOrDefault();


                        output = (int)SL.SeekerDetailId;
                        Seekeroutputmessage = "Hello" + usr.FirstName + "" + usr.LastName + "You had Allocated having slot Number:" + SL.ParkingSlotNumber + " with Reference Number:" + output;

                        return(Seekeroutputmessage);
                    }
                    else
                    {
                        SeekerDetail SL = objectContext.SeekerDetails.Where(s => s.EmpNo == seeker.EmpNo && s.CreatedDate.Year == seeker.CreatedDate.Year && s.CreatedDate.Month == seeker.CreatedDate.Month && s.CreatedDate.Day == seeker.CreatedDate.Day).SingleOrDefault();


                        output = (int)SL.SeekerDetailId;

                        return(" sorry" + usr.FirstName + "" + usr.LastName + "You already raised a Request Today and Your Slot Number is" + SL.ParkingSlotNumber);
                    }
                }
                else
                {
                    var          Res = objectContext.Database.ExecuteSqlCommand("sp_seekerdetails @EmpNo={0}, @ParkingSlotNumber={1},@CreatedDate={2},@SlotReleasedDate={3}, @AllocationType={4},@OperationType={5}", seeker.EmpNo, null, seeker.CreatedDate, seeker.CreatedDate, 0, 1);
                    SeekerDetail SL  = objectContext.SeekerDetails.Where(s => s.EmpNo == seeker.EmpNo && s.CreatedDate.Year == seeker.CreatedDate.Year && s.CreatedDate.Month == seeker.CreatedDate.Month && s.CreatedDate.Day == seeker.CreatedDate.Day).SingleOrDefault();


                    output = (int)SL.SeekerDetailId;

                    Seekeroutputmessage = "Hello" + usr.FirstName + "" + usr.LastName + "Thank you for request a slot You are Under waiting list with Reference Number:" + output;

                    return("Seekeroutputmessage");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }