Ejemplo n.º 1
0
        public GuYuanGroup UpdateSingle(int id, GuYuanGroupReq data)
        {
            GuYuanGroup model = db.GuYuanGroup.Find(id);

            SetGuYuanGroup(model, data);
            db.SaveChanges();
            return(model);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 设置model,如果不为空就设置,如果为空则和之前一样
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public GuYuanGroup SetGuYuanGroup(GuYuanGroup model, GuYuanGroupReq data)
        {
            if (data.Departmentid != null)
            {
                model.Departmentid = data.Departmentid.Value;
            }
            if (!string.IsNullOrEmpty(data.DepartmentName))
            {
                model.DepartmentName = data.DepartmentName;
            }
            if (!string.IsNullOrEmpty(data.GroupName))
            {
                model.GroupName = data.GroupName;
            }
            if (!string.IsNullOrEmpty(data.State))
            {
                model.State = data.State;
            }
            if (!string.IsNullOrEmpty(data.OptName))
            {
                model.OptName = data.OptName;
            }
            if (data.OptId != null)
            {
                model.OptId = data.OptId.Value;
            }
            if (data.createdate != null && data.createdate != DateTime.MinValue && data.createdate != SqlDateTime.MinValue.Value)
            {
                model.createdate = data.createdate.Value;
            }
            if (data.projectid != null)
            {
                model.ProjectId = data.projectid.Value;
            }

            return(model);
        }