protected override void DataPortal_Create() { this.LoadProperty(DateProperty, DateTime.Now.Date); this.LoadProperty(UserIdProperty, BusinessPrincipal.GetCurrentIdentity().UserId); this.BusinessRules.CheckRules(); }
public void Hour_New() { var hour = HourService.HourNew(); Assert.IsTrue(hour.IsNew, "IsNew should be true"); Assert.IsTrue(hour.IsDirty, "IsDirty should be true"); Assert.IsFalse(hour.IsValid, "IsValid should be false"); Assert.IsTrue(hour.IsSelfDirty, "IsSelfDirty should be true"); Assert.IsFalse(hour.IsSelfValid, "IsSelfValid should be false"); Assert.IsFalse(hour.IsArchived, "IsArchived should be false"); Assert.IsTrue(hour.UserId == BusinessPrincipal.GetCurrentIdentity().UserId, string.Format("UserId should be '{0}'", BusinessPrincipal.GetCurrentIdentity().UserId)); Assert.IsTrue(hour.Date == DateTime.Now.Date, string.Format("Date should be '{0:d}'", DateTime.Now.Date)); // we init some values, so we want to make sure the rules are captured so // we reset the values to default hour.UserId = 0; hour.Date = DateTime.MaxValue.Date; Assert.IsTrue(ValidationHelper.ContainsRule(hour, DbType.Int32, "ProjectId"), "ProjectId should be required"); Assert.IsTrue(ValidationHelper.ContainsRule(hour, DbType.Int32, "UserId"), "UserId should be required"); Assert.IsTrue(ValidationHelper.ContainsRule(hour, DbType.DateTime, "Date"), "Date should be required"); Assert.IsTrue(ValidationHelper.ContainsRule(hour, DbType.Decimal, "Duration"), "Duration should be required"); }
public static HourInfoList HourFetchInfoList(DateTime startDate, DateTime endDate) { return(HourService.HourFetchInfoList( new HourCriteria { UserId = new[] { BusinessPrincipal.GetCurrentIdentity().UserId }, Date = new DateRangeCriteria(startDate, endDate) })); }
public static FilterInfoList FilterFetchInfoList(string target) { return(FilterService.FilterFetchInfoList( new FilterCriteria { Target = target, CreatedBy = BusinessPrincipal.GetCurrentIdentity().UserId })); }
public static TaskInfoList TaskFetchInfoList() { return(TaskService.TaskFetchInfoList( new TaskCriteria { AssignedTo = new[] { BusinessPrincipal.GetCurrentIdentity().UserId }, IsArchived = false })); }
public static bool CanDeleteObject(Filter filter) { if (Csla.ApplicationContext.User.IsInRole(Role.FullControl.ToString()) || (Csla.ApplicationContext.User.IsInRole(Role.Contribute.ToString()) && filter.CreatedBy == BusinessPrincipal.GetCurrentIdentity().UserId)) { return(true); } return(false); }
public static FeedInfoList FeedFetchInfoList(int maximumRecords) { return(FeedService.FeedFetchInfoList( new FeedCriteria { CreatedBy = BusinessPrincipal.GetCurrentIdentity().UserId, SortBy = "CreatedDate", SortOrder = ListSortDirection.Descending, MaximumRecords = maximumRecords })); }
public static bool CanDeleteObject(Hour hour) { if (Csla.ApplicationContext.User.IsInRole(Role.FullControl.ToString()) || (Csla.ApplicationContext.User.IsInRole(Role.Contribute.ToString()) && hour.UserId == BusinessPrincipal.GetCurrentIdentity().UserId && !hour.IsArchived)) { return(true); } return(false); }
public static bool UserPasswordChange(string newPassword, string confirmPassword, IMessenger messenger) { if (!newPassword.Equals(confirmPassword)) { throw new Csla.Rules.ValidationException("New password and confirmation password must be the same."); } var user = User.FetchUser( new UserCriteria { UserId = BusinessPrincipal.GetCurrentIdentity().UserId }); if (user != null) { var password = newPassword; user.SetPassword(password); user = user.Save(); if (messenger == null) { messenger = MessageHelper.InitializeMessageForUserPasswordChange(user.Email); } messenger.Message = messenger.Message.Replace(MessageParameter.Password, password); messenger.Send(); } else { throw new ArgumentException("No such user exists."); } return(true); }