public void Upsert(Piece_Details pieceDetails)
 {
     using (var dataEntities = new TempDataEntities())
     {
         var newDetail = dataEntities.Piece_Details.FirstOrDefault(detail => detail.TempId == pieceDetails.TempId) ?? new Piece_Details();
         newDetail.CoveredPieces          = pieceDetails.CoveredPieces;
         newDetail.Type                   = pieceDetails.Type;
         newDetail.Author                 = pieceDetails.Author;
         newDetail.Period                 = pieceDetails.Period;
         newDetail.Culture                = pieceDetails.Culture;
         newDetail.Origin                 = pieceDetails.Origin;
         newDetail.Shape                  = pieceDetails.Shape;
         newDetail.Inscriptions           = pieceDetails.Inscriptions;
         newDetail.Description            = pieceDetails.Description;
         newDetail.Remarks                = pieceDetails.Remarks;
         newDetail.Collection             = pieceDetails.Collection;
         newDetail.ConservationType       = pieceDetails.ConservationType;
         newDetail.Valuation              = pieceDetails.Valuation;
         newDetail.RawMaterial            = pieceDetails.RawMaterial;
         newDetail.ManufacturingTechnique = pieceDetails.ManufacturingTechnique;
         newDetail.DecorativeTechnique    = pieceDetails.DecorativeTechnique;
         newDetail.Provenance             = pieceDetails.Provenance;
         newDetail.AcquisitionMethod      = pieceDetails.AcquisitionMethod;
         newDetail.Location               = pieceDetails.Location;
         if (newDetail.TempId == default)
         {
             newDetail.TempId = pieceDetails.TempId;
             dataEntities.Piece_Details.Add(newDetail);
         }
         dataEntities.SaveChanges();
     }
 }
Example #2
0
 public void Delete(int id)
 {
     using (var entities = new TempDataEntities())
     {
         entities.Pieces.Remove(entities.Pieces.First(p => p.TempId == id));
         entities.SaveChanges();
     }
 }
Example #3
0
 public void Delete(int id, string type)
 {
     using (var entities = new TempDataEntities())
     {
         var measures   = entities.Measures;
         var identifier = measures.FirstOrDefault(i => i.Type.Equals(type) && i.TempId.Equals(id));
         if (identifier != default)
         {
             measures.Remove(identifier);
             entities.SaveChanges();
         }
     }
 }
Example #4
0
 public void Upsert(int id, string type, float?value)
 {
     using (var entities = new TempDataEntities())
     {
         var measure = entities.Measures.FirstOrDefault(m => m.TempId == id && m.Type == type);
         if (measure == default)
         {
             measure = new Measures();
             entities.Measures.Add(measure);
         }
         measure.TempId = id;
         measure.Type   = type;
         measure.Value  = (float)(value ?? 0F);
         entities.SaveChanges();
     }
 }
 public void Upsert(int id, string type, string value)
 {
     using (var entities = new TempDataEntities())
     {
         var identifier = entities.Identifiers.FirstOrDefault(i => i.TempId == id && i.Type == type);
         if (identifier == default)
         {
             identifier = new Identifiers();
             entities.Identifiers.Add(identifier);
         }
         identifier.TempId = id;
         identifier.Type   = type;
         identifier.Value  = value;
         entities.SaveChanges();
     }
 }
Example #6
0
 public void Upsert(Users user)
 {
     using (var dataEntities = new TempDataEntities())
     {
         var local = dataEntities.Users.FirstOrDefault(u => u.Email == user.Email) ?? new Users();
         local.Email    = user.Email;
         local.Password = user.Password;
         local.Name     = user.Name;
         local.Role     = user.Role;
         if (local.Id == default)
         {
             dataEntities.Users.Add(local);
         }
         dataEntities.SaveChanges();
     }
 }
Example #7
0
        public void Upsert(Pieces pieces)
        {
            using (var entities = new TempDataEntities())
            {
                var piece = entities.Pieces.FirstOrDefault(p => p.TempId == pieces.TempId) ?? new Pieces();
                piece.Subject = pieces.Subject;

                if (piece.TempId == default)
                {
                    piece.TempId    = pieces.TempId;
                    piece.CreatedBy = pieces.CreatedBy;
                    entities.Pieces.Add(piece);
                }

                entities.SaveChanges();
            }
        }