コード例 #1
0
ファイル: IOwnerSevice.cs プロジェクト: ezeroone/evts
        public bool UpdateOwner(VehicleOwner owner)
        {
            try
            {
                var model = GetOwner(owner.Id);
                if (model == null)
                {
                    _repository.Add(owner);
                }
                else
                {
                    owner.ModifiedDate = DateTime.Now;
                    _repository.Update<VehicleOwner>(owner);
                }

                _unitOfWork.Commit();

            }
            catch (Exception ex)
            {
                return false;
            }
      
            return true;
        }
コード例 #2
0
ファイル: AccountController.cs プロジェクト: ezeroone/evts
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var profile = (Profile)model;
                var result = _commonService.UserManager().Create(profile, model.Password);
                result = _commonService.UserManager().AddToRole(profile.Id, RoleNames.OWNER);
                //var t = _ownerService.GeteDefaultTitle(1);
                //var q = _ownerService.GeteDefaultSecretQuestion(1);

                var owner = new VehicleOwner
                {
                    FirstName = model.FirstName,
                    Email = model.Email,
                    Mobile = model.MobileNumber,
                    //User=profile,
                    UserId = profile.Id,
                    CreatedDate=DateTime.Now,
                    ModifiedDate=DateTime.Now,
                    IsActive=false,
                    IsDeleted=false,
                    //Title = t,
                   // SecretQuestion=q
                };

                var res=_ownerService.UpdateOwner(owner);

                if (result.Succeeded)
                {
                    GPSTracking.Service.EmailService.SendEmail("*****@*****.**", model.Email, "Your account created with itrackmyvehicle.com", "Dear " + model.FirstName + ", <br/> your account has been successfully created with itrackmyvehicle.com, please setup your profile & add your vehicles <br/><br/>  Thanks <br/>team itrackmyvehicle.com");
                   // GPSTracking.Service.EmailService.SendEmail("*****@*****.**", "*****@*****.**", "from itrackmyvehicle.com", "this is a test email");

                    await SignInAsync(profile, isPersistent: false);
                    return RedirectToAction("Index", "Owner");
                }

                AddErrors(result);
            }
          
            model.AvailableCountries = _commonService.GetCountries().ToList();
            // If we got this far, something failed, redisplay form
            return View(model);
        }