예제 #1
0
 public static ComputerPartDetail ToCompuerPartDetail(ComputerPartDetailDTO dto)
 {
     return(new ComputerPartDetail
     {
         Id = dto.Id,
         Description = dto.Description,
         Condition = dto.Condition,
         Location = dto.Location,
         PartType = dto.PartType,
         Price = dto.Price,
         Remarks = dto.Remarks
     });
 }
예제 #2
0
        public void InitializeFields(int id)
        {
            IComputerPartsService computerPartsService = new ComputerPartsService();

            // read part detail from db
            ComputerPartDetailDTO partDetail = computerPartsService.GetDetailsById(id);

            // update dialog
            Description = partDetail.Description;
            Condition   = partDetail.Condition;
            PartType    = partDetail.PartType;
            Price       = partDetail.Price;
            Location    = partDetail.Location;
            Remarks     = partDetail.Remarks;
        }
예제 #3
0
 public void Update(int id, ComputerPartDetailDTO detail)
 {
     using (var db = new ComputerPartsContext())
     {
         var partToEdit = db.ComputerParts.Where(a => a.Id == id).SingleOrDefault();
         if (partToEdit != null)
         {
             partToEdit.Description = detail.Description;
             partToEdit.Condition   = detail.Condition;
             partToEdit.PartType    = detail.PartType;
             partToEdit.Location    = detail.Location;
             partToEdit.Price       = detail.Price;
             partToEdit.Remarks     = detail.Remarks;
             db.SaveChanges();
         }
     }
 }
예제 #4
0
        public int Append(ComputerPartDetailDTO computerPart)
        {
            int id = -1;

            using (var db = new ComputerPartsContext())
            {
                ComputerParts computerParts = new ComputerParts
                {
                    Description = computerPart.Description,
                    Condition   = computerPart.Condition,
                    PartType    = computerPart.PartType,
                    Location    = computerPart.Location,
                    Price       = computerPart.Price,
                    Remarks     = computerPart.Remarks
                };
                db.ComputerParts.Add(computerParts);
                db.SaveChanges();
                id = computerParts.Id;
            }
            return(id);
        }