/* -- For getting the addressess * internal static Address GetUserAddress(AddressDto address) * { * return new Address * { * Home_Address = address.Home_Address, * City = address.City, * State = address.State, * Zip_Code = address.Zip_Code * }; * }*/ /* -- For getting the wendies --*/ internal static Wendy GetWendys(WendyDto wendy) { return(new Wendy { Size = wendy.Size, NumOfRooms = wendy.NumOfRooms, Price = wendy.Price, Picture = wendy.Picture }); }
public IActionResult AddCategory([FromBody] WendyDto wendy) { if (ModelState.IsValid) { try { repo.AddWendy(wendy); return(Ok(string.Format("Successfully added a wendy house."))); } catch (Exception e) { return(Ok(e.Message)); } } return(Ok("Failed to add a wendy, try again")); }
/* Add wendy with a certain wood */ public virtual void AddWendy(WendyDto wendy) { try { var wen = Helper.GetWendys(wendy); var wood = db.Woods.FirstOrDefault(c => c.Wood_Type.Equals(wendy.Wood.Wood_Type, StringComparison.CurrentCultureIgnoreCase)); wen.Wood_Id = wood.Wood_Id; db.Wendies.Add(wen); db.SaveChanges(); } catch (Exception e) { throw new Exception(e.Message); } }