public void DeleteField(int id)
        {
            IdeaFieldsDao i = _ctx.IdeaFields.First(d => d.FieldId == id);

            _ctx.IdeaFields.Remove(i);
            _ctx.SaveChanges();
        }
 private Field ConvertFieldToDomain(IdeaFieldsDao dao)
 {
     return(new Field {
         Id = dao.FieldId,
         Idea = new Idea {
             Id = dao.IdeaId
         },
         Text = dao.FieldText
     });
 }
 private ClosedField ConvertClosedFieldToDomain(IdeaFieldsDao dao)
 {
     return(new ClosedField
     {
         Id = dao.FieldId,
         Idea = new Idea {
             Id = dao.IdeaId
         },
         Options = ExtensionMethods.StringToList(dao.FieldStrings)
     });
 }
 private VideoField ConvertVideoFieldToDomain(IdeaFieldsDao dao)
 {
     return(new VideoField
     {
         Id = dao.FieldId,
         Idea = new Idea {
             Id = dao.IdeaId
         },
         Url = dao.Url
               //UploadedImage = DTO.UploadedImage
     });
 }
 private ImageField ConvertImageFieldToDomain(IdeaFieldsDao dao)
 {
     return(new ImageField
     {
         Id = dao.FieldId,
         Idea = new Idea {
             Id = dao.IdeaId
         },
         Url = dao.Url
               //UploadedVideo= DTO.UploadedVideo
     });
 }
 private MapField ConvertMapFieldToDomain(IdeaFieldsDao dao)
 {
     return(new MapField
     {
         Id = dao.FieldId,
         Idea = new Idea {
             Id = dao.IdeaId
         },
         LocationX = dao.LocationX,
         LocationY = dao.LocationY
     });
 }
        public void Update(Idea obj)
        {
            IdeasDao newIdea   = ConvertToDao(obj);
            IdeasDao foundIdea = _ctx.Ideas.First(i => i.IdeaId == obj.Id);

            if (foundIdea != null)
            {
                foundIdea.Title         = newIdea.Title;
                foundIdea.Reported      = newIdea.Reported;
                foundIdea.ReviewByAdmin = newIdea.ReviewByAdmin;
                foundIdea.Visible       = newIdea.Visible;
                foundIdea.VoteCount     = newIdea.VoteCount;
                foundIdea.RetweetCount  = newIdea.RetweetCount;
                foundIdea.ShareCount    = newIdea.ShareCount;
                foundIdea.Status        = newIdea.Status;
                foundIdea.VerifiedUser  = newIdea.VerifiedUser;
                foundIdea.DeviceId      = newIdea.DeviceId;
                foundIdea.IsDeleted     = newIdea.IsDeleted;
                _ctx.Ideas.Update(foundIdea);
            }

            if (obj.Field != null)
            {
                IdeaFieldsDao newTextField   = ConvertToDao(obj.Field);
                IdeaFieldsDao foundTextField = _ctx.IdeaFields.First(f => f.FieldId == obj.Field.Id);
                if (foundTextField != null)
                {
                    foundTextField.FieldText = newTextField.FieldText;
                    _ctx.IdeaFields.Update(foundTextField);
                }
            }

            if (obj.Cfield != null)
            {
                IdeaFieldsDao newCField   = ConvertToDao(obj.Cfield);
                IdeaFieldsDao foundCField = _ctx.IdeaFields.First(f => f.FieldId == obj.Cfield.Id);
                if (foundCField != null)
                {
                    foundCField.FieldStrings = newCField.FieldStrings;
                    _ctx.IdeaFields.Update(foundCField);
                }
            }

            if (obj.Mfield != null)
            {
                IdeaFieldsDao newMField   = ConvertToDao(obj.Mfield);
                IdeaFieldsDao foundMField = _ctx.IdeaFields.First(f => f.FieldId == obj.Mfield.Id);
                if (foundMField != null)
                {
                    foundMField.LocationX = newMField.LocationX;
                    foundMField.LocationY = newMField.LocationY;
                    foundMField.Url       = newMField.Url;
                    _ctx.IdeaFields.Update(foundMField);
                }
            }

            if (obj.Ifield != null)
            {
                IdeaFieldsDao newIField   = ConvertToDao(obj.Ifield);
                IdeaFieldsDao foundIField = _ctx.IdeaFields.First(f => f.FieldId == obj.Ifield.Id);
                if (foundIField != null)
                {
                    foundIField.Url           = newIField.Url;
                    foundIField.UploadedImage = newIField.UploadedImage;
                    _ctx.IdeaFields.Update(foundIField);
                }
            }

            if (obj.Vfield != null)
            {
                IdeaFieldsDao newVField   = ConvertToDao(obj.Vfield);
                IdeaFieldsDao foundVField = _ctx.IdeaFields.First(f => f.FieldId == obj.Vfield.Id);
                if (foundVField != null)
                {
                    foundVField.Url           = newVField.Url;
                    foundVField.UploadedMedia = newVField.UploadedMedia;
                    _ctx.IdeaFields.Update(foundVField);
                }
            }

            _ctx.SaveChanges();
        }