Beispiel #1
0
        public static Update SaveUpdate(Update u)
        {
            using (var dc = new UpdateManagerClassesDataContext())
            {
                if (u.Id.Equals(Guid.Empty))
                {
                    u.Id           = Guid.NewGuid();
                    u.DateCreated  = DateTime.Now;
                    u.DateModified = DateTime.Now;

                    var dbo = new Entities.Update();
                    Mapper.Map(u, dbo);

                    dc.Updates.InsertOnSubmit(dbo);
                    dc.SubmitChanges();

                    return(MapUpdate(dbo));
                }
                else
                {
                    u.DateModified = DateTime.Now;

                    var dbo = dc.Updates.SingleOrDefault(x => x.Id == u.Id);
                    if (dbo != null)
                    {
                        Mapper.Map(u, dbo);
                        dc.SubmitChanges();
                    }

                    return(MapUpdate(dbo));
                }
            }
        }
Beispiel #2
0
        public static Update MapUpdate(Entities.Update dbo)
        {
            var obj = new Update();

            Mapper.Map(dbo, obj);

            obj.UpdateFileIds = GetFildIdsForUpdate(obj.Id);

            return(obj);
        }