public BedGroup Edit(BedGroup newBedGroup) { BedGroup original = GetById(newBedGroup.Id, newBedGroup.UserId); original.BedId = newBedGroup.BedId != 0 ? newBedGroup.BedId : original.BedId; original.GroupId = newBedGroup.GroupId != 0 ? newBedGroup.GroupId : original.GroupId; original.GardenId = newBedGroup.GardenId != 0 ? newBedGroup.GardenId : original.GardenId; return(_repo.Edit(original)); }
internal BedGroup Create(BedGroup BedGroupData) { string sql = @" INSERT INTO bedgroups (bedId, userId, gardenId, groupId) VALUES (@BedId, @UserId, @GardenId, @GroupId); SELECT LAST_INSERT_ID(); "; BedGroupData.Id = _db.ExecuteScalar <int>(sql, BedGroupData); return(BedGroupData); }
public ActionResult <BedGroup> Edit(int id, [FromBody] BedGroup editedBedGroup) { try { string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; editedBedGroup.UserId = userId; editedBedGroup.Id = id; return(Ok(_bgs.Edit(editedBedGroup))); } catch (Exception e) { return(BadRequest(e.Message)); } }
internal BedGroup Edit(BedGroup EditedBedGroup) { string sql = @" UPDATE bedgroups SET bedId = @BedId, groupId = @GroupId, gardenId = @GardenId WHERE (id = @Id AND userId = @UserId); "; _db.Execute(sql, EditedBedGroup); return(EditedBedGroup); }
public ActionResult <BedGroup> Post([FromBody] BedGroup newBedGroup) { try { var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; newBedGroup.UserId = userId; Bed bed = _bs.GetById(newBedGroup.BedId, userId); newBedGroup.GardenId = bed.GardenId; return(Ok(_bgs.Create(newBedGroup))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult BedGroup() { List <BedGroup> CategoryList = new List <BedGroup>(); Property p = new Property(); DataSet ds = new DataSet(); p.OnTable = "FetchBedGroup"; ds = dl.FetchBedGroup_sp(p); List <SelectListItem> Categoryinventory = new List <SelectListItem>(); Categoryinventory.Add(new SelectListItem { Text = "Select Floor", Value = "" }); foreach (DataRow dr in ds.Tables[1].Rows) { Categoryinventory.Add(new SelectListItem { Text = dr["Name"].ToString(), Value = dr["FId"].ToString() }); } ViewBag.Categoryinventory = new SelectList(Categoryinventory, "Value", "Text"); try { foreach (DataRow item in ds.Tables[0].Rows) { BedGroup m = new BedGroup(); m.BGId = item["BGId"].ToString(); m.GName = item["GName"].ToString(); m.Description = item["Description"].ToString(); m.FId = item["FId"].ToString(); m.Name = item["Name"].ToString(); m.AddedBy = item["AddedBy"].ToString(); m.IsActive = item["IsActive"].ToString(); CategoryList.Add(m); } ViewBag.CategoryList = CategoryList; } catch (Exception e) { } return(View()); }
public ActionResult BedGroup(BedGroup c) { HttpCookie rxgoAdminCookie = Request.Cookies["rxgoAdmin"]; string AddedBy = rxgoAdminCookie.Values["Hid"]; c.AddedBy = AddedBy; try { if (dl.InsertBedGroup_Sp(c) > 0) { TempData["MSG"] = "Bed Group Added Successfully"; } } catch (Exception ex) { TempData["MSG"] = "Something went wrong."; return(Redirect("/Bed/BedGroup")); } TempData["MSG"] = "Bed Group Added Successfully."; return(Redirect("/Bed/BedGroup")); }
public BedGroup Create(BedGroup newBedGroup) { return(_repo.Create(newBedGroup)); }