private void ValidateProjectStatus(SPItemEventProperties properties)
{
try
{
string projectStatus = properties.AfterProperties[Constants.ProjectStatus].ToString();
if (projectStatus == Constants.ColorRed || projectStatus == Constants.ColorYellow || projectStatus == Constants.ColorGreen)
{
var list = properties.List;
string fieldSupervisor = properties.AfterProperties[Constants.SupervisorFieldName].ToString();
if (!fieldSupervisor.IsNullOrEmpty())
{
var fldSupervisoruser = properties.Web.Lists[list.ToString()].Fields.GetField(Constants.SupervisorFieldName) as SPFieldUser;
var fldSupervisorValue = fldSupervisoruser.GetFieldValue(fieldSupervisor) as SPFieldUserValue;
var supervisorUser = fldSupervisorValue.User as SPUser;
if (!IsUserMemberOfGroup(supervisorUser, ResourceHelper.SiteGroupName))
{
properties.Cancel = true;
properties.ErrorMessage = Constants.ErrorMessageFromPMO;
}
}
string fieldSupervisorAdvisor = properties.AfterProperties[Constants.SupervisorAdvisorFieldName].ToString();
if (!fieldSupervisorAdvisor.IsNullOrEmpty())
{
var fldSupervisorAdvisoruser = properties.Web.Lists[list.ToString()].Fields.GetField(Constants.SupervisorAdvisorFieldName) as SPFieldUser;
var fldSupervisorAdvisorValue = fldSupervisorAdvisoruser.GetFieldValue(fieldSupervisorAdvisor) as SPFieldUserValue;
var supervisorAdvisoruser = fldSupervisorAdvisorValue.User as SPUser;
if (!IsUserMemberOfGroup(supervisorAdvisoruser, ResourceHelper.SiteGroupName))
{
properties.Cancel = true;
properties.ErrorMessage = Constants.ErrorMessageFromPMO;
}
}
}
}
Czy ktoś ma pomysł na metode która będzie wywoływana dwa razy w metodzie ValidateProjectStatus, żeby nie powtarzać kodu ?