Example #1
0
        public async Task <IHttpActionResult> PutAnotherModel(int id, AnotherModel anotherModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != anotherModel.Id)
            {
                return(BadRequest());
            }

            db.Entry(anotherModel).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AnotherModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 static void Test()
 {
     var model      = new ProjectValue();
     var model2     = new AnotherModel();
     var viewModel  = model2.HydrateEntityToVM();
     var viewModel2 = model2.HydrateEntityToVM();
 }
Example #3
0
        public IActionResult Create(CustomModel model, AnotherModel anotherModel)
        {
            this.data.Models.Add(model);
            this.anotherData.OtherModels.Add(anotherModel);

            return(this.Ok());
        }
Example #4
0
 public void CreateAnother(AnotherModel another)
 {
     if (another == null)
     {
         throw new ArgumentNullException(nameof(another));
     }
     _anotherContext.AnotherModels.Add(another);
 }
Example #5
0
        public async Task <IHttpActionResult> GetAnotherModel(int id)
        {
            AnotherModel anotherModel = await db.AnotherModels.FindAsync(id);

            if (anotherModel == null)
            {
                return(NotFound());
            }

            return(Ok(anotherModel));
        }
    //
    // GET: /EditorExample/
    public ActionResult Index()
    {
        AnotherModel model = new AnotherModel();

        model.InnerProp1 = new InnerModel {
            Input = "test 1"
        };
        model.InnerProp2 = new InnerModel {
            Input = "test 2"
        };
        return(View(model));
    }
Example #7
0
        public async Task <IHttpActionResult> PostAnotherModel(AnotherModel anotherModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AnotherModels.Add(anotherModel);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = anotherModel.Id }, anotherModel));
        }
Example #8
0
        public async Task <IHttpActionResult> DeleteAnotherModel(int id)
        {
            AnotherModel anotherModel = await db.AnotherModels.FindAsync(id);

            if (anotherModel == null)
            {
                return(NotFound());
            }

            db.AnotherModels.Remove(anotherModel);
            await db.SaveChangesAsync();

            return(Ok(anotherModel));
        }
Example #9
0
 public void UpdateAnother(AnotherModel another)
 {
     // _anotherContext.AnotherModels.Add(another); // this instruction is not necessary it seems
 }