示例#1
0
        public IActionResult Post([FromBody] Models.Sortimat.BatchHourReport item)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (item == null)
                {
                    return(BadRequest());
                }

                this.OnBatchHourReportCreated(item);
                this.context.BatchHourReports.Add(item);
                this.context.SaveChanges();

                return(Created($"odata/Sortimat/BatchHourReports/{item.RowID}", item));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
示例#2
0
        public IActionResult PutBatchHourReport(int key, [FromBody] Models.Sortimat.BatchHourReport newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (newItem == null || (newItem.RowID != key))
                {
                    return(BadRequest());
                }

                this.OnBatchHourReportUpdated(newItem);
                this.context.BatchHourReports.Update(newItem);
                this.context.SaveChanges();

                var itemToReturn = this.context.BatchHourReports.Where(i => i.RowID == key);
                return(new ObjectResult(SingleResult.Create(itemToReturn)));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
示例#3
0
 partial void OnBatchHourReportUpdated(Models.Sortimat.BatchHourReport item);