Ejemplo n.º 1
0
        public HttpResponseMessage SaveMstModel(MstModel model)
        {
            try
            {
                var editModels = from d in db.MstModels where d.Id == Convert.ToInt32(model.Id) select d;
                if (editModels.Any())
                {
                    var editModel = editModels.FirstOrDefault();

                    editModel.FullName    = model.FullName;
                    editModel.Description = model.Description;

                    db.SubmitChanges();

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Ejemplo n.º 2
0
        public Int32 PostMstModel(MstModel model)
        {
            try
            {
                Data.MstModel newModel = new Data.MstModel()
                {
                    FullName    = model.FullName,
                    Description = model.Description
                };

                db.MstModels.InsertOnSubmit(newModel);
                db.SubmitChanges();

                return(newModel.Id);
            }
            catch (Exception e)
            {
                return(0);
            }
        }