Exemplo n.º 1
0
        public override bool DeleteData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DeliveryTermMngEntities context = CreateContext())
                {
                    DeliveryTerm dbItem = context.DeliveryTerm.FirstOrDefault(o => o.DeliveryTermID == id);
                    if (dbItem == null)
                    {
                        notification.Message = "Delivery Term not found!";
                        return(false);
                    }
                    else
                    {
                        context.DeliveryTerm.Remove(dbItem);
                        context.SaveChanges();

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message
                };
                return(false);
            }
        }
Exemplo n.º 2
0
        public override bool UpdateData(int id, ref DTO.DeliveryTermMng.DeliveryTerm dtoItem, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DeliveryTermMngEntities context = CreateContext())
                {
                    DeliveryTerm dbItem = null;
                    if (id == 0)
                    {
                        dbItem = new DeliveryTerm();
                        context.DeliveryTerm.Add(dbItem);
                    }
                    else
                    {
                        dbItem = context.DeliveryTerm.FirstOrDefault(o => o.DeliveryTermID == id);
                    }

                    if (dbItem == null)
                    {
                        notification.Message = "Delivery Term not found!";
                        return(false);
                    }
                    else
                    {
                        converter.DTO2BD_Material(dtoItem, ref dbItem);
                        context.SaveChanges();

                        dtoItem = GetData(dbItem.DeliveryTermID, out notification);

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message
                };
                return(false);
            }
        }
Exemplo n.º 3
0
 public void DTO2BD_Material(DTO.DeliveryTermMng.DeliveryTerm dtoItem, ref DeliveryTerm dbItem)
 {
     AutoMapper.Mapper.Map <DTO.DeliveryTermMng.DeliveryTerm, DeliveryTerm>(dtoItem, dbItem);
 }