示例#1
0
        public IActionResult Post([FromBody] SalesPointPhoto item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            item.Id = _context.SalesPointPhotos.Count() + 1;
            _context.SalesPointPhotos.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetSalesPointPhoto", new { id = item.Id }, item));
        }
示例#2
0
        public IActionResult Update(long id, [FromBody] SalesPointPhoto item)
        {
            if (item == null || item.Id != id)
            {
                return(BadRequest());
            }

            var salesPointPhoto = _context.SalesPointPhotos.FirstOrDefault(t => t.Id == id);

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

            salesPointPhoto.FileId       = item.FileId;
            salesPointPhoto.SalesPointId = item.SalesPointId;
            salesPointPhoto.Type         = item.Type;

            _context.SalesPointPhotos.Update(salesPointPhoto);
            _context.SaveChanges();
            return(new NoContentResult());
        }