public void RoomIntegration_Add_ShouldBeOk() { // Cenário Room room = ObjectMother.GetRoom(); // Ação Room result = _service.Add(room); // Verifica result.Should().NotBeNull(); result.Id.Should().BeGreaterThan(0); }
public void RoomService_Save_ShouldBeOk() { Room room = ObjectMotherRoom.GetRoom(); _mockRepository .Setup(m => m.Save(room)) .Returns(new Room { Id = 1 }); Room result = _service.Add(room); result.Should().NotBeNull(); result.Id.Should().BeGreaterThan(0); _mockRepository.Verify(m => m.Save(room)); }
public async Task <IActionResult> Save(TRequest <RoomRequest> request) { if (request == null) { return(NotFound()); } var response = new Response <int>(); try { if (request.value.Id == 0) { response.Data = await _roomService.Add(request.value); response.Message = "Thêm thành công"; response.Success = true; } else { response.Data = await _roomService.Update(request.value); response.Message = "Sửa thành công"; response.Success = true; } } catch (Exception ex) { response.Success = false; response.Message = ex.Message + "," + ex.InnerException; } return(Ok(response)); }
public IActionResult Create([Bind("RoomID,Ref,Name")] Room room) { if (ModelState.IsValid) { service.Add(room); return(RedirectToAction(nameof(Index))); } return(View(room)); }
public string Add() { _roomService.Add(new Room { Id = 1, OtelId = 2, RoomName = "Deneme Oda1" }); return("Added"); }
private void btnRoomAdd_Click(object sender, EventArgs e) { _roomService.Add(new Room() { RoomTypeId = Convert.ToInt32(dgvEditAllRooms.SelectedRows[0].Cells[1].Value), Number = Convert.ToByte(dgvEditAllRooms.SelectedRows[0].Cells[2].Value), Name = dgvEditAllRooms.SelectedRows[0].Cells[3].Value.ToString() }); MessageBox.Show("Sisteme yeni oda eklendi!"); LoadRooms(); }
private void AddClicked(object sender, RoutedEventArgs e) { if (isValidValues()) { room r = roomService.CreateRoom(int.Parse(bedsNr.Text), int.Parse(roomNr.Text), (string)quality.SelectedItem, (string)status.SelectedItem); roomService.Add(r); this.Close(); } }
public IActionResult AddRooms(string id, RoomInput room) { try { return(Ok(_roomService.Add(id, room))); } catch (System.Exception e) { _logger.LogError(e, "error: {0}", e.Message); return(BadRequest()); } }
public IActionResult OpenNewRoom(Room Room) { try { _roomService.Add(Room); return(Ok("Successfull")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ValidationResult Add(Room room) { BeginTransaction(); var roomModel = room.ToModel(); ValidationResult = _roomService.Add(roomModel).ToViewModel(); if (ValidationResult.IsValid) { Commit(); } return(ValidationResult); }
public ActionResult AddRoom(RoomDto dto, int hid, int tid) { dto.RoomType_id = tid; dto.HotelBlock_id = hid; // if() int i = _roomService.Add(dto); roomrecDto roomrecDto = new roomrecDto(); roomrecDto.Room_Id = i; roomrecDto.Recoed = "تم أضافة الغرفة "; _RoomRecServices.Add(roomrecDto); return(RedirectToAction("AddEquipment", "Equipment", new { Rid = i })); }
public JsonResult Post([FromBody] RoomViewModel room) { try { _roomService.Add(new Room { Name = room.Name }); return(Json(new { message = "room created" })); } catch (Exception ex) { return(Json(new { message = ex.Message })); } }
public ActionResult Create(Room room, HttpPostedFileBase image = null) { if (ModelState.IsValid) { if (image != null) { room.ImageType = image.ContentType; room.RoomImage = new byte[image.ContentLength]; image.InputStream.Read(room.RoomImage, 0, image.ContentLength); } _roomService.Add(room); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(_departmentService.GetAll(), "DepartmentId", "DepartmentName", room.DepartmentId); return(View(room)); }
public ActionResult PostRoom(RoomDTO room) { var temp = _roomService.GetBy(room.RoomId); if (temp != null) return BadRequest(new { success = false, message = "Mã phòng đã tồn tại" }); if (!Regex.IsMatch(room.RoomId, regex)) return BadRequest(new { success = false, message = "Mã phòng không hợp lệ. Mã hợp lệ bắt đầu bằng P và kết thúc bằng ba số. Ví dụ : P101,P202" }); // if (room.RoomId == "") // return BadRequest (new {success = false, message = "Vui lòng nhập mã phòng"}); _roomService.Add(room); //roomService.Update(room); return Ok(new { success = true, message = "Thêm thành công" }); }
public RoomViewModel Add(RoomViewModel roomViewModel) { var room = Mapper.Map <Room>(roomViewModel); room.Activate(); //Must be improved. var roomRet = _roomService.Add(room); if (roomRet.validationResult.IsValid) { if (!Commit()) { } } roomViewModel = Mapper.Map <RoomViewModel>(roomRet); return(roomViewModel); }
public ActionResult Add(Models.Room.AddViewModel model) { if (!ModelState.IsValid) { return(View(model)); } Data.Entity.Room room = new Data.Entity.Room(); room.Name = model.Name; room.Price = model.Price; room.Floor = model.Floor; var result = _roomService.Add(room); if (result > 0) { return(RedirectToAction(nameof(RoomController.List))); } else { ViewBag.ErrorMessage = "Not Saved"; return(View(model)); } }
public HttpResponseMessage AddRoom(HttpRequestMessage request, RoomEntity roomEntity) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { if (roomEntity != null) { var room = _roomService.Add(roomEntity); response = request.CreateResponse(HttpStatusCode.Created, room); } else { request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } } return response; })); }
public IHttpActionResult Post(Room room) { return(Ok(_roomService.Add(room))); }
public async Task <IActionResult> Add([FromBody] RoomModel data) { var dataEntity = await _roomService.Add(RoomMapper.Map(data)); return(Ok(dataEntity)); }
public ActionResult AddRoom(Room room) { return(Json(roomService.Add(room))); }
public async Task <JsonResult> Create(RoomEntityModel room) { return(new JsonResult(await _roomlogic.Add(new Room(0, room.Name, room.Description)))); }
public ContentResult CreateRoom(Room room) { roomService.Add(room); roomService.Save(); return(Content("<p>The room was created successfully!</p>")); }
public Room Add(Room room) { return(_roomService.Add(room)); }
public Room Add([FromBody] Room room) { return(_roomService.Add(room)); }