Ejemplo n.º 1
0
 public BedGroupViewModel EditBedsByGroupId(BedGroupViewModel newBed)
 {
     if (newBed.DatePlanted != null && newBed.DateFertilized != null && newBed.Name != null && newBed.Height != 0 && newBed.Width != 0 && newBed.Img != null && newBed.Description != null)
     {
         return(_repo.EditBedsInGroup(newBed));
     }
     throw new Exception("Some properties are null");
 }
Ejemplo n.º 2
0
 public ActionResult <BedGroupViewModel> EditBedsByGroupId(int id, [FromBody] BedGroupViewModel editedBed)
 {
     try
     {
         editedBed.BedGroupId = id;
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         editedBed.UserId = userId;
         return(Ok(_bs.EditBedsByGroupId(editedBed)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 3
0
        internal BedGroupViewModel EditBedsInGroup(BedGroupViewModel bed)
        {
            string sql = @"
        UPDATE beds
        SET
            name = @Name,
            description = @Description,
            width = @Width,
            height = @Height,
            datePlanted = @DatePlanted,
            dateFertilized = @DateFertilized,
            img = @Img
        WHERE (userId = @UserId AND bedId FROM bedgroups WHERE (userId = @UserId AND groupId = @BedGroupId) = id);";

            _db.Execute(sql, bed);
            return(bed);
        }