예제 #1
0
        public VolunteerResult EditVolunteer(Volunteer a, Volunteer b)
        {
            if (a == null || a.StudentNum == 0)
            {
                return(VolunteerResult.Error(VolunteerResult.EditVolunteerErrorEnum.NonExistingVolunteer));
            }
            var v = database.Volunteers.SingleOrDefault(o => o.StudentNum == a.StudentNum);

            v.StudentNum = b.StudentNum;
            v.Name       = b.Name;
            v.Class      = b.Class;
            v.Mobile     = b.Mobile;
            v.Room       = b.Room;
            v.Email      = b.Email;
            Save();
            v = database.Volunteers.SingleOrDefault(o => o.StudentNum == a.StudentNum);
            Volunteer target = v;
            Volunteer edited = v;

            //Volunteer edited = FindVolunteer(b.StudentNum);
            if (edited.Mobile != target.Mobile || edited.Email != target.Email || edited.Room != target.Room)//日志字符串改成“修改联系方式”,现在联系方式:手机 电子邮件 寝室
            {
                bool logresult = VolunteerOperationSucceeded(string.Format("修改原学号:{0},姓名:{1}的志愿者基本信息.现学号:{2},姓名:{3}", target.StudentNum, target.Name, edited.StudentNum, edited.Name), target, LogType.EditContact, true);
            }
            else
            {
                bool logresult = VolunteerOperationSucceeded(string.Format("修改原学号:{0},姓名:{1}的志愿者基本信息.现学号:{2},姓名:{3}", target.StudentNum, target.Name, edited.StudentNum, edited.Name), target, LogType.EditVolunteer, true);
            }
            return(VolunteerResult.Success());
        }