示例#1
0
        public Projection Insert(CreateProjection value)
        {
            using (var tran = db.Database.BeginTransaction(System.Data.IsolationLevel.RepeatableRead))
            {
                var toInsert = new DbProjection()
                {
                    FilmId = value.FilmId,
                    RoomId = value.RoomId,
                    Start  = value.Start
                };
                db.Projections.Add(toInsert);

                db.SaveChanges();
                tran.Commit();

                return(new Model.Projection(toInsert.Id, toInsert.FilmId, toInsert.RoomId, toInsert.Start));
            }
        }
示例#2
0
        public Projection Edit(int id, CreateProjection value)
        {
            var dbProjection = db.Projections.FirstOrDefault(p => p.Id == id);

            if (dbProjection == null)
            {
                return(null);
            }
            else
            {
                dbProjection.FilmId = value.FilmId;
                dbProjection.RoomId = value.RoomId;
                dbProjection.Start  = value.Start;


                db.SaveChanges();

                return(new Model.Projection(dbProjection.Id, dbProjection.FilmId, dbProjection.RoomId, dbProjection.Start));
            }
        }