Example #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 (ClientCountryMngEntities context = CreateContext())
                {
                    ClientCountry dbItem = context.ClientCountry.FirstOrDefault(o => o.ClientCountryID == id);
                    if (dbItem == null)
                    {
                        notification.Message = "ClientCountry not found!";
                        return(false);
                    }
                    else
                    {
                        context.ClientCountry.Remove(dbItem);
                        context.SaveChanges();

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message
                };
                return(false);
            }
        }
Example #2
0
        public override bool UpdateData(int id, ref DTO.ClientCountryMng.ClientCountry dtoItem, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (ClientCountryMngEntities context = CreateContext())
                {
                    ClientCountry dbItem = null;
                    if (id == 0)
                    {
                        dbItem = new ClientCountry();
                        context.ClientCountry.Add(dbItem);
                    }
                    else
                    {
                        dbItem = context.ClientCountry.FirstOrDefault(o => o.ClientCountryID == id);
                    }

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

                        dtoItem = GetData(dbItem.ClientCountryID, out notification).Data;

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message
                };
                return(false);
            }
        }
Example #3
0
 public void DTO2BD_ClientCountry(DTO.ClientCountryMng.ClientCountry dtoItem, ref ClientCountry dbItem)
 {
     AutoMapper.Mapper.Map <DTO.ClientCountryMng.ClientCountry, ClientCountry>(dtoItem, dbItem);
 }