Exemplo n.º 1
0
        public async Task UpdateProfileDoesNotAddHiddenProfileToResultsCacheWhenNotPreviouslyCachedTest()
        {
            var expected     = Model.Create <UpdatableProfile>().Set(x => x.Status = ProfileStatus.Hidden);
            var profile      = Model.Create <Profile>().Set(x => x.BannedAt = null);
            var changeResult = Model.Create <ProfileChangeResult>().Set(x => x.ProfileChanged = true);
            var cacheResults = new List <ProfileResult>();

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                cache.GetProfileResults().Returns(cacheResults);
                store.GetProfile(profile.Id, tokenSource.Token).Returns(profile);
                calculator.CalculateChanges(profile, expected).Returns(changeResult);

                await sut.UpdateProfile(profile.Id, expected, tokenSource.Token).ConfigureAwait(false);

                cache.DidNotReceive().StoreProfileResults(Arg.Any <ICollection <ProfileResult> >());
            }
        }
Exemplo n.º 2
0
        public async Task UpdateProfileRemovesHiddenProfileFromResultsCacheTest()
        {
            var expected     = Model.Create <UpdatableProfile>().Set(x => x.Status = ProfileStatus.Hidden);
            var profile      = Model.Create <Profile>().Set(x => x.BannedAt = null);
            var changeResult = Model.Create <ProfileChangeResult>().Set(x => x.ProfileChanged = true);
            var cacheResults = new List <ProfileResult>
            {
                Model.Create <ProfileResult>().Set(x => x.Id = profile.Id)
            };

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                cache.GetProfileResults().Returns(cacheResults);
                store.GetProfile(profile.Id, tokenSource.Token).Returns(profile);
                calculator.CalculateChanges(profile, expected).Returns(changeResult);

                await sut.UpdateProfile(profile.Id, expected, tokenSource.Token).ConfigureAwait(false);

                cache.Received().StoreProfileResults(
                    Verify.That <ICollection <ProfileResult> >(x => x.Should().NotContain(y => y.Id == profile.Id)));
            }
        }
Exemplo n.º 3
0
        public IActionResult UpdateUser(ProfileCommands model)
        {
            try
            {
                ProfileCommand profile = new ProfileCommand()
                {
                    Email            = model.Email,
                    FullName         = model.FullName,
                    About            = model.About,
                    ImageProfile     = model.ImageProfile,
                    ImageProfilePath = model.ImageProfilePath
                };
                bool isSuccess = _authService.UpdateProfile(profile);
                if (isSuccess)
                {
                    SuccessModel.SuccessCode    = "200";
                    SuccessModel.SuccessMessage = "Update Completed.";

                    return(Ok(SuccessModel));
                }
                else
                {
                    ErrorModel.ErrorCode    = "400";
                    ErrorModel.ErrorMessage = "Not found";
                    return(BadRequest(ErrorModel));
                }
            }
            catch (Exception ex)
            {
                ErrorModel.ErrorMessage = ex.Message;
                ErrorModel.ErrorCode    = "500";

                return(StatusCode(500, ErrorModel));
            }
        }
Exemplo n.º 4
0
        public async Task DeleteProfileRemovesProfileFromResultsCacheTest()
        {
            var profile      = Model.Create <Profile>();
            var cacheResults = new List <ProfileResult>
            {
                Model.Create <ProfileResult>().Set(x => x.Id = profile.Id)
            };

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                store.GetProfile(profile.Id, tokenSource.Token).Returns(profile);
                calculator.RemoveAllCategoryLinks(profile).Returns(new ProfileChangeResult());
                store.DeleteProfile(profile.Id, tokenSource.Token).Returns(profile);
                cache.GetProfileResults().Returns(cacheResults);

                await sut.DeleteProfile(profile.Id, tokenSource.Token).ConfigureAwait(false);

                cache.Received().StoreProfileResults(
                    Verify.That <ICollection <ProfileResult> >(x => x.Should().NotContain(y => y.Id == profile.Id)));
            }
        }
Exemplo n.º 5
0
        public async Task BanProfileDoesNotProcessChangesWhenNoneFoundTest()
        {
            var profile  = Model.Create <Profile>();
            var bannedAt = DateTimeOffset.UtcNow.AddDays(-2);

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                calculator.RemoveAllCategoryLinks(profile).Returns(new ProfileChangeResult());
                store.BanProfile(profile.Id, Arg.Any <DateTimeOffset>(), tokenSource.Token).Returns(profile);

                await sut.BanProfile(profile.Id, bannedAt, tokenSource.Token).ConfigureAwait(false);

                await processor.DidNotReceive().Execute(
                    Arg.Any <Profile>(),
                    Arg.Any <ProfileChangeResult>(),
                    Arg.Any <CancellationToken>()).ConfigureAwait(false);
            }
        }
Exemplo n.º 6
0
        public async Task UpdateProfileStoresProfileWithOriginalProfileBannedAtValueTest()
        {
            var expected     = Model.Create <UpdatableProfile>();
            var profile      = Model.Create <Profile>().Set(x => x.BannedAt = DateTimeOffset.UtcNow);
            var changeResult = Model.Create <ProfileChangeResult>().Set(x => x.ProfileChanged = true);

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                store.GetProfile(profile.Id, tokenSource.Token).Returns(profile);
                calculator.CalculateChanges(profile, expected).Returns(changeResult);

                await sut.UpdateProfile(profile.Id, expected, tokenSource.Token).ConfigureAwait(false);

                await processor.Received().Execute(
                    Arg.Is <Profile>(x => x.BannedAt == profile.BannedAt),
                    Arg.Any <ProfileChangeResult>(),
                    tokenSource.Token).ConfigureAwait(false);

                cache.DidNotReceive().StoreProfile(Arg.Any <Profile>());
            }
        }
Exemplo n.º 7
0
        public async Task UpdateProfileUpdatesProfileInResultsCacheTest(ProfileStatus status)
        {
            var expected     = Model.Create <UpdatableProfile>().Set(x => x.Status = status);
            var profile      = Model.Create <Profile>().Set(x => x.BannedAt = null);
            var changeResult = Model.Create <ProfileChangeResult>().Set(x => x.ProfileChanged = true);
            var cacheResults = new List <ProfileResult>
            {
                Model.Create <ProfileResult>().Set(x => x.Id = profile.Id)
            };

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                cache.GetProfileResults().Returns(cacheResults);
                store.GetProfile(profile.Id, tokenSource.Token).Returns(profile);
                calculator.CalculateChanges(profile, expected).Returns(changeResult);

                await sut.UpdateProfile(profile.Id, expected, tokenSource.Token).ConfigureAwait(false);

                // This is a mouthful. We want to make sure that the profile results being put into
                // the cache contains only a single item matching our updated profile and that has
                // all the same data as the updated profile
                cache.Received().StoreProfileResults(
                    Verify.That <ICollection <ProfileResult> >(
                        x => x.Single(y => y.Id == profile.Id)
                        .Should().BeEquivalentTo(expected, opt => opt.ExcludingMissingMembers())));
            }
        }
Exemplo n.º 8
0
        public async Task UpdateProfileCalculatesAndProcessesChangesForUpdatedProfileTest()
        {
            var expected = Model.Create <UpdatableProfile>();
            var profile  = Model.Create <Profile>().Set(x =>
            {
                x.AcceptCoC = true;
                x.AcceptToS = true;
            });
            var changeResult = Model.Create <ProfileChangeResult>().Set(x => x.ProfileChanged = true);

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                store.GetProfile(profile.Id, tokenSource.Token).Returns(profile);
                calculator.CalculateChanges(profile, expected).Returns(changeResult);

                await sut.UpdateProfile(profile.Id, expected, tokenSource.Token).ConfigureAwait(false);

                await processor.Received().Execute(
                    Verify.That <Profile>(x =>
                                          x.Should().BeEquivalentTo(expected, opt => opt.ExcludingMissingMembers())),
                    changeResult,
                    tokenSource.Token).ConfigureAwait(false);
            }
        }
Exemplo n.º 9
0
        public async Task UpdateProfileDoesNotProcessProfileChangesWhenNoChangeFoundTest()
        {
            var expected     = Model.Create <UpdatableProfile>();
            var profile      = Model.Create <Profile>();
            var changeResult = Model.Create <ProfileChangeResult>().Set(x => x.ProfileChanged = false);

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                store.GetProfile(profile.Id, tokenSource.Token).Returns(profile);
                calculator.CalculateChanges(profile, expected).Returns(changeResult);

                await sut.UpdateProfile(profile.Id, expected, tokenSource.Token).ConfigureAwait(false);

                await processor.DidNotReceive().Execute(
                    Arg.Any <Profile>(),
                    Arg.Any <ProfileChangeResult>(),
                    Arg.Any <CancellationToken>()).ConfigureAwait(false);
            }
        }
Exemplo n.º 10
0
        public ActionResult Profile(ProfileCommand command)
        {
            Check.Argument.IsNotNull(command, "command");

            UserDTO model = userService.GetByName(command.UserName);

            return(View(model));
        }
 public MainWindowButtons()
 {
     InitializeComponent();
     LogInCommand      = new LogInCommand();
     GraphCommand      = new GraphCommand();
     ProfileCommand    = new ProfileCommand();
     EnterMealsCommand = new EnterMealsCommand();
     //MainGrid.DataContext = new MainWindowVM();
 }
Exemplo n.º 12
0
        public ActionResult GenerateKey(ProfileCommand command)
        {
            Check.Argument.IsNotNull(command, "command");

            UserResult result = userService.RegenerateApiKey(command.UserName);

            object model = result.User != null ? new { apiKey = result.User.ApiKey } : null;

            return(this.AdaptivePostRedirectGet(result.RuleViolations, model, Url.Profile()));
        }
Exemplo n.º 13
0
        public async Task <ActionResult <ProfileViewModel> > ProfileAsync()
        {
            var userName = User.Claims
                           .FirstOrDefault(x => x.Type == "username").Value;
            ProfileCommand query = new ProfileCommand
            {
                UserName = userName
            };

            return(await Mediator.Send(query));
        }
Exemplo n.º 14
0
        public Profile GetUser(int uid)
        {
            NameValueCollection Params = new NameValueCollection();
            string CommandName;
            Params.Add("uid", uid.ToString());
            Params.Add("fields", "uid, first_name, last_name, nickname, sex, bdate, city, country" +
                           "photo, photo_medium, photo_big");
            CommandName = "users.get";

            var command = new ProfileCommand(CommandName, Params);
            command.ExecuteCommand();
            return command.Fill().FirstOrDefault<Profile>();
        }
Exemplo n.º 15
0
 public MainWindowVM()
 {
     Model             = new MainModel();
     MainWindowButtons = new MainWindowButtons();
     initLogIn();
     LogInCommand                      = new LogInCommand();
     GraphCommand                      = new GraphCommand();
     EnterMealsCommand                 = new EnterMealsCommand();
     ProfileCommand                    = new ProfileCommand();
     LogInCommand.ShowLogIn           += LogInCommand_ShowlogIn;
     ProfileCommand.ShowProfile       += ProfileCommand_ShowProfile;
     EnterMealsCommand.ShowEnterMeals += MealCommand_ShowEnterMeals;
     GraphCommand.ShowGraph           += GraphCommand_ShowGraph;
 }
Exemplo n.º 16
0
        public void DeleteProfileThrowsExceptionWithEmptyIdTest()
        {
            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            Func <Task> action = async() => await sut.DeleteProfile(Guid.Empty, CancellationToken.None)
                                 .ConfigureAwait(false);

            action.Should().Throw <ArgumentException>();
        }
Exemplo n.º 17
0
        public void UpdateProfileThrowsExceptionWithNullProfileTest()
        {
            var profileId  = Guid.NewGuid();
            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            Func <Task> action = async() => await sut.UpdateProfile(profileId, null, CancellationToken.None)
                                 .ConfigureAwait(false);

            action.Should().Throw <ArgumentNullException>();
        }
Exemplo n.º 18
0
        public void BanProfileThrowsExceptionWithEmptyIdTest()
        {
            var bannedAt = DateTimeOffset.UtcNow.AddDays(-2);

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            Func <Task> action = async() => await sut.BanProfile(Guid.Empty, bannedAt, CancellationToken.None)
                                 .ConfigureAwait(false);

            action.Should().Throw <ArgumentException>();
        }
Exemplo n.º 19
0
        public async Task DeleteProfileIgnoresWhenProfileNotFoundTest()
        {
            var profileId = Guid.NewGuid();

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                await sut.DeleteProfile(profileId, tokenSource.Token).ConfigureAwait(false);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Add a new command to the profile.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns></returns>
        public VoiceAttackBuilder AddCommand(Command command)
        {
            ProfileCommand c = new ProfileCommand
            {
                //Setup command from object.
                CommandString   = command.Phrase,
                UseSpokenPhrase = command.IsVoiced,
                Async           = command.IsAsync,
                BaseId          = command.ID.ToString(),
                Enabled         = command.IsEnabled,
                SessionEnabled  = command.IsEnabled,
                Id = command.ID.ToString(),

                //Standard stuff.
                ExecType = 3,
                ProcessOverrideActiveWindow = true,
                LostFocusBackCompat         = true,
                OriginId         = Guid.Empty.ToString(),
                SourceProfile    = Guid.Empty.ToString(),
                lastEditedAction = Guid.Empty.ToString()
            };

            //Add the actions.
            List <ProfileCommandCommandAction> actions = new List <ProfileCommandCommandAction>();

            foreach (IAction action in command.Actions)
            {
                ProfileCommandCommandAction a = action.GetAction();
                //a.KeyCodes = new ProfileCommandCommandActionKeyCodes();
                a.Caption      = "";
                a._caption     = "";
                a.RandomSounds = "";
                actions.Add(a);
            }

            c.ActionSequence = actions.ToArray();

            //Add the command.
            List <ProfileCommand> commands = vap.Commands.ToList();

            commands.Add(c);
            vap.Commands = commands.ToArray();

            return(this);
        }
Exemplo n.º 21
0
        public bool UpdateProfile(ProfileCommand profile)
        {
            var user = _userRepository.GetByEmail(profile.Email);

            if (user != null)
            {
                user.FullName         = profile.FullName;
                user.About            = profile.About;
                user.ImageProfile     = profile.ImageProfile;
                user.ImageProfilePath = profile.ImageProfilePath;
                _userRepository.Update(user);
                _userRepository.SaveChange();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 22
0
        public async Task BanProfileReturnsNullWhenProfileNotInStoreTest()
        {
            var profileId = Guid.NewGuid();
            var bannedAt  = DateTimeOffset.UtcNow.AddDays(-2);

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                var actual = await sut.BanProfile(profileId, bannedAt, tokenSource.Token).ConfigureAwait(false);

                actual.Should().BeNull();
                cache.DidNotReceive().StoreProfile(Arg.Any <Profile>());
            }
        }
Exemplo n.º 23
0
        public async Task UpdateProfileStoresProfileWithAcceptedToSAtDependingOnConsentTest(bool originalConsent,
                                                                                            bool updatedConsent, bool timeSet)
        {
            var expected = Model.Create <UpdatableProfile>().Set(x => x.AcceptToS = updatedConsent);
            var profile  = Model.Create <Profile>().Set(x =>
            {
                x.AcceptToS     = originalConsent;
                x.AcceptedToSAt = DateTimeOffset.UtcNow.AddYears(-1);
            });
            var changeResult = Model.Create <ProfileChangeResult>().Set(x => x.ProfileChanged = true);

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                store.GetProfile(profile.Id, tokenSource.Token).Returns(profile);
                calculator.CalculateChanges(profile, expected).Returns(changeResult);

                await sut.UpdateProfile(profile.Id, expected, tokenSource.Token).ConfigureAwait(false);

                if (timeSet)
                {
                    await processor.Received().Execute(
                        Verify.That <Profile>(x => x.AcceptedToSAt.Should().BeCloseTo(DateTimeOffset.UtcNow, 1000)),
                        Arg.Any <ProfileChangeResult>(),
                        tokenSource.Token).ConfigureAwait(false);
                }
                else
                {
                    await processor.Received().Execute(
                        Arg.Is <Profile>(x => x.AcceptedToSAt == profile.AcceptedToSAt),
                        Arg.Any <ProfileChangeResult>(),
                        tokenSource.Token).ConfigureAwait(false);
                }
            }
        }
Exemplo n.º 24
0
        public async Task BanProfileRemovesProfileFromCacheTest()
        {
            var expected = Model.Create <Profile>().Set(x => x.Status = ProfileStatus.Unavailable);
            var bannedAt = DateTimeOffset.UtcNow.AddDays(-2);

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                calculator.RemoveAllCategoryLinks(expected).Returns(new ProfileChangeResult());
                store.BanProfile(expected.Id, bannedAt, tokenSource.Token).Returns(expected);

                await sut.BanProfile(expected.Id, bannedAt, tokenSource.Token).ConfigureAwait(false);

                cache.Received().RemoveProfile(expected.Id);
            }
        }
Exemplo n.º 25
0
        public async Task DeleteProfileRemovesProfileFromStoreTest()
        {
            var profile = Model.Create <Profile>();

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                store.GetProfile(profile.Id, tokenSource.Token).Returns(profile);
                calculator.RemoveAllCategoryLinks(profile).Returns(new ProfileChangeResult());
                store.DeleteProfile(profile.Id, tokenSource.Token).Returns(profile);

                await sut.DeleteProfile(profile.Id, tokenSource.Token).ConfigureAwait(false);

                await store.Received().DeleteProfile(profile.Id, tokenSource.Token).ConfigureAwait(false);
            }
        }
Exemplo n.º 26
0
        public async Task BanProfileDoesNotCacheProfileResultWhenNoResultsAreCachedTest()
        {
            var profile = Model.Create <Profile>().Set(x => x.BannedAt = DateTimeOffset.UtcNow);

            var store      = Substitute.For <IProfileStore>();
            var calculator = Substitute.For <IProfileChangeCalculator>();
            var processor  = Substitute.For <IProfileChangeProcessor>();
            var cache      = Substitute.For <IProfileCache>();

            var sut = new ProfileCommand(store, calculator, processor, cache);

            using (var tokenSource = new CancellationTokenSource())
            {
                calculator.RemoveAllCategoryLinks(profile).Returns(new ProfileChangeResult());
                store.BanProfile(profile.Id, profile.BannedAt.Value, tokenSource.Token).Returns(profile);
                cache.GetProfileResults().Returns((ICollection <ProfileResult>)null);

                await sut.BanProfile(profile.Id, profile.BannedAt.Value, tokenSource.Token).ConfigureAwait(false);

                cache.DidNotReceive().StoreProfileResults(Arg.Any <ICollection <ProfileResult> >());
            }
        }
Exemplo n.º 27
0
        public async Task <IActionResult> Update(long id, [FromBody] ProfileCommand command)
        {
            try
            {
                var userInfo = await _userInfo.GetUserProfileById(id);

                userInfo.BirthDate = command.BirthDate;
                userInfo.Cpf       = command.Cpf;
                userInfo.Gender    = command.Gender;
                userInfo.LastName  = command.LastName;
                userInfo.Name      = command.Name;
                userInfo.PhotoUrl  = command.PhotoUrl;

                await _unitOfWork.Commit();

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Exemplo n.º 28
0
        public MainViewModel()
        {
            SelectedProfile = new ProfileModel();
            //pulls models from external source but no logic which collections are for
            try
            {
                profileCommand = new ProfileCommand(_connectionString);
                //list that comes from the database will be added to Emplyees Bindable collection
                Profiles.AddRange(profileCommand.GetList());

                EmployeeCommand employeeCommand = new EmployeeCommand(_connectionString);
                //list that comes from the database will be added to Emplyees Bindable collection
                Employees.AddRange(employeeCommand.GetList());

                CompanyCommand companyCommand = new CompanyCommand(_connectionString);
                //list that comes from the database will be added to Emplyees Bindable collection
                Companies.AddRange(companyCommand.GetList());
            }
            catch (Exception ex)
            {
                AppStatus = ex.Message;
                NotifyOfPropertyChange(() => AppStatus);
            }
        }
 public HomeViewModel()
 {
     _profileCommand = new ProfileCommand(this);
     GetAnniversaries();
 }
 public async Task <IActionResult> Put([FromBody] ProfileCommand profile)
 {
     return(await _mediator.Send(profile) ? Ok() : (IActionResult)BadRequest());
 }