Beispiel #1
0
        public ActionResult CreateAuthenticatedRecord(AutorizedUserRecord model)
        {
            var pickedCar = db.CarClientSet.FirstOrDefault(x => x.CarCarId == model.CurrentCar.CarId);

            var newRecord = db.RecordSet.Create();

            newRecord.RecordId           = Guid.NewGuid();
            newRecord.CarClientCarNumber = pickedCar.CarNumber;
            if (pickedCar.PriorityBox != null && pickedCar.PriorityCarWasher != null)
            {
                newRecord.PriorityWasher = db.CarWasherSet.FirstOrDefault(x => x.CarWasherId == pickedCar.PriorityCarWasher).Surname;
                newRecord.PriorityBox    = pickedCar.PriorityBox;
            }
            if (newRecord.PriorityBox != null && newRecord.PriorityWasher != null)
            {
                newRecord.BoxesBoxId           = pickedCar.PriorityBox;
                newRecord.CarWasherCarWasherId = pickedCar.PriorityCarWasher;
            }
            else
            {
                newRecord.BoxesBoxId           = db.BoxesSet.FirstOrDefault(x => x.Description == "Default").BoxId;
                newRecord.CarWasherCarWasherId = db.CarWasherSet.FirstOrDefault(x => x.Surname == "Default" && x.Name == "Default").CarWasherId;
            }
            newRecord.DateTime = Convert.ToDateTime(model.DateRecord.Month + "/" + model.DateRecord.Day + "/" +
                                                    model.DateRecord.Year + " " + model.TimeRecord.Hour + ":" + model.TimeRecord.Minute + ":" + model.TimeRecord.Second,
                                                    CultureInfo.InvariantCulture);
            db.RecordSet.Add(newRecord);
            db.SaveChanges();
            var newOrder = db.OrderSet.Create();

            newOrder.OrderId        = Guid.NewGuid();
            newOrder.RecordRecordId = newRecord.RecordId;
            db.OrderSet.Add(newOrder);
            db.SaveChanges();
            return(RedirectToAction("ShowRecordList", newRecord));
        }
Beispiel #2
0
        public ActionResult CreateAuthenticatedRecord()
        {
            var             userId           = User.Identity.GetUserId();
            ApplicationUser currentAppClient = UserManager.Users.FirstOrDefault(x => x.Id == userId);

            Client client = db.ClientSet.FirstOrDefault(x => x.ClientId == currentAppClient.ClientGuid);
            List <CarClientSet> listClientCars = db.CarClientSet.Where(x => x.ClientClientId == currentAppClient.ClientGuid).ToList();

            var recordModel = new AutorizedUserRecord();

            recordModel.ClientGuid = client.ClientId;
            recordModel.Name       = client.Name;
            recordModel.Surname    = client.Surname;
            recordModel.Patronymic = client.Patronymic;
            recordModel.Phone      = client.PhoneNumer;
            recordModel.UserCars   = new List <Car>();
            foreach (var item in listClientCars)
            {
                Car userCar = db.CarSet.FirstOrDefault(x => x.CarId == item.CarCarId);
                recordModel.UserCars.Add(userCar);
            }

            return(View(recordModel));
        }