コード例 #1
0
        public List <VehicleServiceCompany> GetVehicleCompanies(string uid)
        {
            List <VehicleServiceCompany> VehicleServiceCompanies = new List <VehicleServiceCompany>();
            VehicleServiceCompanyOwner   CurrentOwner            = ServiceBookContext.VehicleServiceCompanyOwner.FirstOrDefault(x => x.UID == uid);

            foreach (var cco in CurrentOwner.CCO)
            {
                VehicleServiceCompanies.Add(cco.VehicleServiceCompany);
            }
            return(VehicleServiceCompanies);
        }
コード例 #2
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    ServiceBookContext         database = new ServiceBookContext();
                    VehicleServiceCompanyOwner VehicleServiceCompanyOwner = new VehicleServiceCompanyOwner();

                    VehicleServiceCompanyOwner.Email       = model.Email;
                    VehicleServiceCompanyOwner.FirstName   = model.FirstName;
                    VehicleServiceCompanyOwner.LastName    = model.LastName;
                    VehicleServiceCompanyOwner.UID         = user.Id;
                    VehicleServiceCompanyOwner.PhoneNumber = model.PhoneNumber;


                    VehicleServiceCompanyOwner.CCO = null;
                    database.VehicleServiceCompanyOwner.Add(VehicleServiceCompanyOwner);

                    database.SaveChanges();
                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Service"));
                }
                AddErrors(result);
            }



            // If we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #3
0
        public void DeletVehicleServiceCompany(string uid, VehicleServiceCompany VehicleServiceCompany)
        {
            VehicleServiceCompanyOwner CurrentOwner = ServiceBookContext.VehicleServiceCompanyOwner.FirstOrDefault(x => x.UID == uid);
            CCO deletVehicleServiceCompany          = ServiceBookContext.CCO.FirstOrDefault(x => x.COID == CurrentOwner.ID && x.CID == VehicleServiceCompany.ID);


            if (deletVehicleServiceCompany.VehicleServiceCompany != null)
            {
                if (deletVehicleServiceCompany.VehicleServiceCompany.WorkingPoints != null)
                {
                    foreach (var workingPoint in deletVehicleServiceCompany.VehicleServiceCompany.WorkingPoints)
                    {
                        WorkingPointRepository.DeletWorkingPoint(workingPoint);
                    }
                }
            }
            ServiceBookContext.CCO.Remove(deletVehicleServiceCompany);
            ServiceBookContext.SaveChanges();
        }
コード例 #4
0
        public CCO AddVehicleServiceCompany(string uid, VehicleServiceCompany VehicleServiceCompany)
        {
            VehicleServiceCompanyOwner CurrentOwner = ServiceBookContext.VehicleServiceCompanyOwner.FirstOrDefault(x => x.UID == uid);
            VehicleServiceCompany      Company      = ServiceBookContext.VehicleServiceCompany.FirstOrDefault(x => x.ServiceName == VehicleServiceCompany.ServiceName);
            var CCO = ServiceBookContext.CCO.FirstOrDefault(x => x.VehicleServiceCompanyOwner.ID == CurrentOwner.ID && x.VehicleServiceCompany.ServiceName == VehicleServiceCompany.ServiceName);
            CCO cco = new CCO();

            if (CCO == null)
            {
                cco.VehicleServiceCompanyOwner = CurrentOwner;
                if (Company != null)
                {
                    cco.VehicleServiceCompany = Company;
                }
                else
                {
                    cco.VehicleServiceCompany = VehicleServiceCompany;
                }
                cco.VehicleServiceCompany.Flag = 0;

                ServiceBookContext.CCO.Add(cco);
                ServiceBookContext.SaveChanges();
            }
            else
            {
                if (CCO.VehicleServiceCompany.Flag == 0)
                {
                    return(null);
                }
                CCO.VehicleServiceCompany.Flag = 0;
                ServiceBookContext.SaveChanges();
                cco = CCO;
            }


            return(cco);
        }