Exemple #1
0
        public ActionResult Register(RegisterParkingViewModel model)
        {
            if(ModelState.IsValid)
            {
                Parking parking = BusinessManager.Instance.Parkings.Find(model.CNPJ);

                if (parking == null)
                {
                    Client dailyClient = new Client();

                    parking = model.ToParking();
                    BusinessManager.Instance.Parkings.Add(parking);
                    dailyClient.Email = "daily@" + parking.Name.Replace(" ", "_").ToLower() + ".com";
                    BusinessManager.Instance.Clients.Add(dailyClient);

                    BusinessManager.Instance.Clients.AttachToParking(dailyClient, parking.CNPJ);

                    return RedirectToAction("Index", "GlobalAdmin");
                }

                ModelState["CNPJ"].Errors.Add("Já existe um estacionamento com este CNPJ");
            }

            return View(model);
        }
Exemple #2
0
        public ActionResult SaveChangesLocal(RegisterParkingViewModel model)
        {
            if (ModelState.IsValid)
            {
                Parking parking = BusinessManager.Instance.Parkings.Find(model.CNPJ);

                if (parking != null)
                {
                    parking = model.ToParking();
                    BusinessManager.Instance.Parkings.Update(parking);

                    return RedirectToAction("Index", "LocalAdmin");
                }
            }

            return View(model);
        }