Example #1
0
        public bool RegisterIn(long id_loc_place, long id_sts, string Date, long id_vis_param)
        {
            bool Result = true;



            visit vis = new visit();
            vis.id_ts = id_sts;
            vis.id_location_place = id_loc_place;
            vis.DateIn = Date;
            vis.DateOut = "dateout";
            vis.FirstAttemptGoOut = "dateout2";
            vis.NextAttemptGoOut = "dateout3";
            vis.id_vis_param = id_vis_param;
            vis.Status = "Public";
            mp.visit.Add(vis);
            mp.SaveChanges();




            return Result;




        }
Example #2
0
        public ActionResult RegisterIn(ts numb)
        {
                if (ModelState.IsValidField("Number"))
                {
                    visitparameters vp = mp.visitparameters.Where(x => x.Status == "Active").FirstOrDefault();
                    if (vp != null)
                    {
                        reservation r = new reservation();
                        r.FindOnExpired("");
                        ts searchts = mp.ts.Where(x => x.Number == numb.Number & x.Status == "True").FirstOrDefault();
                        if (searchts != null)
                        {
                            visit nvis = new visit();
                                            visit vis = mp.visit.Where(x => x.id_ts == searchts.id_ts & x.DateOut == "dateout").FirstOrDefault();
                                            if (vis == null)
                                            {
                                                place p = new place();
                                                string Log = searchts.Login;
                                                string Date = DateTime.Now.ToString("dd.MM.yy HH:mm");
                                                reservation res = mp.reservation.Where(x => x.Login == Log & x.Status == "Active").FirstOrDefault(); //Существует ли бронь
                                                if (res != null)
                                                {
                                                    if (res.id_alternative_location_place != null)
                                                    {

                                                        nvis.RegisterIn((long)res.id_alternative_location_place, searchts.id_ts, Date, vp.id_vis_param);
                                                        res.DateOutFromActivity = Date;
                                                        res.Status = "Closed";
                                                        res.Description = "Reservation was used";
                                                        mp.Entry(res).State = EntityState.Modified;
                                                        mp.SaveChanges();
                                                        r.Revoke("Reservation was used", res, Date);
                                                        p.ChangeStatus("Occupied", (long)res.id_alternative_location_place, (Int32)res.place.id_alternative_tariff_on_place);
                                                    }
                                                    else
                                                    {
                                                        ViewData["ExceptionRegisterIn"] = "Изначально выбранное место этим ТС было закрыто, других свободных мест на данный момент нет"; //, с броней ничего не делать. Будет ждать свободных, не дождется - умрет сама.
                                                        return View("RegisterIn");
                                                    }
                                                }
                                                else
                                                {
                                                    place autoplace = mp.place.Where(x => x.Status == "Free").OrderBy(x => x.tariffonplace.PriceForHourWithoutAbonement).FirstOrDefault();
                                                    if (autoplace != null)
                                                    {
                                                        nvis.RegisterIn((long)autoplace.id_location_place, searchts.id_ts, Date, vp.id_vis_param);
                                                        p.ChangeStatus("Occupied", (long)autoplace.id_location_place, 0);
                                                    }
                                                    else
                                                    {
                                                        ViewData["ExceptionRegisterIn"] = "Свободных мест нет!";
                                                        return View("RegisterIn");
                                                    }
                                                    //Автоматический расчет мест";
                                                }
                                            }
                                            else
                                            {
                                                ViewData["ExceptionRegisterIn"] = "Возможно, Вы ошиблись при вводе регистрационного номера, т.к. указанное вами ТС уже находится на парковке.";
                                                return View("RegisterIn");
                                            }
                        }
                        else
                        {
                            ViewData["ExceptionRegisterIn"] = "TC не найдено в бд";
                            return View("RegisterIn");
                        }

                    }
                    else
                    {
                        ViewData["ExceptionRegisterIn"] = "Осутствуют параметры въезда, активной записи не найдено";
                        return View("RegisterIn");
                    }







                    return RedirectToAction("Index", new { Controller = "Home"});
                }
                else
                {
                    return View("RegisterIn");
                }
            

        }