public HttpResponseMessage Delete(int id)
        {
            if (id == 0)
            {
                throw new IndexOutOfRangeException();
            }

            ReleaseContext db = new ReleaseContext();

            ImageHelper.DeleteImage(db, db.Images.Single(img => img.Id == id));
            db.SaveChanges();

            return(new HttpResponseMessage(System.Net.HttpStatusCode.OK));
        }
Пример #2
0
        public void SaveModel <TModel>(TModel model) where TModel : class
        {
            IEntityChangesMerger <TModel> merger = null;

            if (typeof(TModel) == typeof(Release))
            {
                merger = (IEntityChangesMerger <TModel>) new ReleaseChangesMerger(context, modelNamespace, modelAssembly);
            }
            else
            {
                merger = new DefaultEntityChangesMerger <TModel>(context, modelNamespace, modelAssembly);
            }

            merger.MergeEntityChanges(model);

            context.SaveChanges();
        }