Esempio n. 1
0
        public ModelJsonRet AddSingleAlbum(string name, byte type, int classId, long stuId)
        {
            object objClassId = null;

            if (classId > 0)
            {
                objClassId = classId;
            }
            object masterId = null;

            if (stuId > 0)
            {
                var stu = UnitOfWork.Repository <SYS_Student>().GetEntitiesAsync(x => x.ID == stuId).Result.FirstOrDefault();
                if (stu != null)
                {
                    masterId   = stuId;
                    objClassId = stu.ClassId;
                }
            }
            var album = new SYS_Album
            {
                SchoolId   = mlUser.School.ID,
                AlbumName  = name,
                Type       = type,
                ClassId    = (int?)objClassId,
                MasterId   = (int?)masterId,
                CreateTime = DateTime.Now,
                PhotoCount = 0,
                UpdateTime = DateTime.Now
            };

            UnitOfWork.Repository <SYS_Album>().AddEntity(album);
            mjRet.code = (byte)UnitOfWork.CommitAsync().Result;
            return(mjRet);
        }
Esempio n. 2
0
        public ModelJsonRet AutoAddStuAlbum(int classId)
        {
            var sql = "select*from SYS_Student where Status=1 and SchoolId=" + mlUser.School.ID + " and ClassId=" + classId +
                      " and ID not in(select s.ID from SYS_Student as s inner join SYS_Album as a on s.ID=a.MasterId where s.Status=1 and s.SchoolId=" + mlUser.School.ID + " and s.ClassId=" + classId + ")";
            var noAlbumStus = UnitOfWork.ExecuteSqlQuery <SYS_Student>(sql).ToList();

            if (noAlbumStus.Count > 0)
            {
                foreach (var stu in noAlbumStus)
                {
                    var album = new SYS_Album
                    {
                        SchoolId   = mlUser.School.ID,
                        AlbumName  = stu.StuName,
                        Type       = (byte)AlbumType.个人相册,
                        ClassId    = stu.ClassId,
                        MasterId   = stu.ID,
                        CreateTime = DateTime.Now,
                        PhotoCount = 0,
                        UpdateTime = DateTime.Now
                    };
                    UnitOfWork.Repository <SYS_Album>().AddEntity(album);
                }
                var isOK = UnitOfWork.CommitAsync().Result;
                if (isOK > 0)
                {
                    mjRet.code = 1;
                }
            }
            return(mjRet);
        }