public RoomTypeViewModel UpdateRoomType(int id, RoomTypeViewModel model) { var roomTypeModel = mapper.Map <RoomType>(model); var roomType = roomTypeRepository.UpdateRoomType(id, roomTypeModel); return(mapper.Map <RoomTypeViewModel>(roomType)); }
public RoomTypeViewModel AddRoomType(RoomTypeViewModel model) { var roomTypeModel = mapper.Map <RoomType>(model); var roomType = roomTypeRepository.AddRoomType(roomTypeModel); return(mapper.Map <RoomTypeViewModel>(roomType)); }
public IHttpActionResult PutRoomType(int id, RoomTypeViewModel roomTypeViewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != roomTypeViewModel.RoomTypeId) { return(BadRequest()); } RoomType roomType = ViewModelMapper.ToModelRoomTypes(roomTypeViewModel); db.Entry(roomType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RoomTypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <bool> UpdateRoomType(RoomTypeViewModel roomType) { try { if (roomType == null) { throw new DataException("Invalid data exception"); } var exist = await UnitOfWork.RoomTypeRepository.GetByIdAsync(roomType.RoomTypeId.Value); if (exist != null) { exist.RoomTypeName = roomType.RoomTypeName; exist.Modified(roomType.UpdateBy.Value); UnitOfWork.RoomTypeRepository.Update(exist); return(await UnitOfWork.CommitAsync()); } throw new DataException("Data not found"); } catch (Exception exception) { Logger.LogError(exception, $"Error exception on insert new item {roomType}"); UnitOfWork.Rollback(); UnitOfWork.Dispose(); throw; } }
public JsonResult GetRoomTypes(RoomTypeViewModel rtViewModel) { PaginationInfo pager = new PaginationInfo(); pager = rtViewModel.Pager; PaginationViewModel pViewModel = new PaginationViewModel(); try { pViewModel.dt = _rtRepo.GetRoomTypes(rtViewModel.RoomType.RoomTypeName, ref pager); pViewModel.Pager = pager; Logger.Debug("RoomType Controller GetRoomTypes"); } catch (Exception ex) { rtViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01")); Logger.Error("RoomType Controller - GetRoomTypes" + ex.ToString()); } return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet)); }
public IActionResult Edit(int id, RoomTypeViewModel model) { if (ModelState.IsValid) { roomTypeService.UpdateRoomType(id, model); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public void PropertiesValidationShouldBePass() { var roomType = new RoomTypeViewModel { RoomTypeName = "Room Type" }; Assert.Equal(0, ViewModelValidator.Validation(roomType).Count); }
public IActionResult Create(RoomTypeViewModel model) { if (ModelState.IsValid) { roomTypeService.AddRoomType(model); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public ActionResult Edit(int?id) { if (id.HasValue) { var model = new RoomTypeViewModel().Single(id.Value); ViewData.Model = model; return(View()); } return(View()); }
public void AddNewRoomTypeTest() { var roomType = new RoomTypeViewModel { RoomTypeName = "Room Type Service Test", CreateBy = Guid.NewGuid() }; Assert.True(_roomTypeService.AddRoomType(roomType).Result); }
public async Task <StatusCodeResult> Update([FromBody] RoomTypeViewModel viewModel) { if (await _service.UpdateAsync(viewModel.ToModel()) == 1) { return(StatusCode((int)HttpStatusCode.OK)); } else { return(StatusCode((int)HttpStatusCode.ExpectationFailed)); } }
public static RoomTypeViewModel ToViewModel(this RoomType model) { if (model != null) { RoomTypeViewModel viewModel = new RoomTypeViewModel(); viewModel.Id = model.Id; viewModel.Name = model.Name; return(viewModel); } return(null); }
public static RoomType ToModel(this RoomTypeViewModel viewModel) { if (viewModel != null) { RoomType model = new RoomType(); model.Id = viewModel.Id; model.Name = viewModel.Name; return(model); } return(null); }
public void Add(RoomTypeViewModel model) { var entity = new HMS_RoomType { RoomTypeName = model.RoomTypeName, Occupancy = model.Occupancy, Active = true }; _genericRepository.Add(entity); }
// GET: System/RoomType public ActionResult Index(int Page = 1) { var model = new RoomTypeViewModel().Query(); var currentPage = Page < 1 ? 1 : Page; var PageSize = 10; var result = model.ToPagedList(currentPage, PageSize); ViewData.Model = result; return(View()); }
public void Edit(RoomTypeViewModel model) { var entity = new HMS_RoomType { RoomTypeName = model.RoomTypeName, Occupancy = model.Occupancy, Active = model.Active, Id = model.Id }; _genericRepository.Edit(entity); }
public RoomTypeViewModel Get(int id) { var model = _genericRepository.Get(id); var viewModel = new RoomTypeViewModel() { RoomTypeName = model.RoomTypeName, Occupancy = model.Occupancy, Active = model.Active, Id = model.Id }; return(viewModel); }
public IHttpActionResult PostRoomType(RoomTypeViewModel roomTypeViewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } RoomType roomType = ViewModelMapper.ToModelRoomTypes(roomTypeViewModel); db.RoomTypes.Add(roomType); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = roomType.RoomTypeId }, ViewModelMapper.ToViewModelRoomTypes(roomType))); }
public ActionResult Edit([Bind(Include = "Id,Bedding,Kitchen,Rooms,BathRooms,SleepsVolume,NightlyRate")] RoomTypeViewModel roomTypeViewModel) { if (Session["AccessLevel"] == null || int.Parse(Session["AccessLevel"].ToString()) == 1 || int.Parse(Session["AccessLevel"].ToString()) == 2 || int.Parse(Session["AccessLevel"].ToString()) == 3) { return(Redirect("~/NotAuthorized/Index")); } if (!ModelState.IsValid) { return(View(roomTypeViewModel)); } _services.PostChangesForEdit(roomTypeViewModel); return(RedirectToAction("Index")); }
public async Task <ActionResult> SaveRoomType(RoomTypeViewModel model) { if (!ModelState.IsValid) { if (model.Id == 0) { return(View("AddRoomType", model)); } return(View("EditRoomType", model)); } await _accommodationService.SaveRoomTypeAsync(model.ToEntity()).ConfigureAwait(false); return(RedirectToAction("Index", new { projectId = model.ProjectId })); }
public void CreateNewRoomType(RoomTypeViewModel roomType) { Db.RoomTypes.Add(new RoomType() { Id = roomType.Id, Bedding = roomType.Bedding, Kitchen = roomType.Kitchen, Rooms = roomType.Rooms, Bathrooms = roomType.BathRooms, SleepsVolume = roomType.SleepsVolume, NightlyRate = roomType.NightlyRate }); Db.SaveChanges(); }
public void PostChangesForEdit(RoomTypeViewModel editRoomType) { Db.Entry(new RoomType() { Id = editRoomType.Id, Bedding = editRoomType.Bedding, Kitchen = editRoomType.Kitchen, Rooms = editRoomType.Rooms, Bathrooms = editRoomType.BathRooms, SleepsVolume = editRoomType.SleepsVolume, NightlyRate = editRoomType.NightlyRate }) .State = EntityState.Modified; Db.SaveChanges(); }
public bool UpdateRoomType(RoomTypeViewModel model) { try { RoomType roomtype = _context.RoomType.Where(x => x.RoomTypeId == model.RoomTypeID).First(); roomtype.Type = model.Type; _context.RoomType.Update(roomtype); _context.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public JsonResult ComboBoxaListele() { List <RoomTypeViewModel> roomTypes = new List <RoomTypeViewModel>(); var odaTurleriListele = postgreServices.OdaTurlerComboBoxDoldur(); foreach (var item in odaTurleriListele) { RoomTypeViewModel odaTurler = new RoomTypeViewModel(); odaTurler.odaTurAdi = item.odaTurAdi; odaTurler.id = item.id; roomTypes.Add(odaTurler); } return(Json(new { roomTypes })); }
/// <summary> /// Maps list of room type to RoomTypeViewModel /// </summary> /// <param name="roomTypeList"></param> /// <returns>List<RoomTypeViewModel></returns> public static BaseResult <List <RoomTypeViewModel> > MapRoomType(BaseResult <List <RoomType> > roomTypeList) { BaseResult <List <RoomTypeViewModel> > responseModelList = new BaseResult <List <RoomTypeViewModel> >(); List <RoomTypeViewModel> modelList = new List <RoomTypeViewModel>(); foreach (var item in roomTypeList.Result) { RoomTypeViewModel roomTypeModel = new RoomTypeViewModel { Id = item.Id, Name = item.Name }; modelList.Add(roomTypeModel); } responseModelList.Result = modelList; return(responseModelList); }
public bool AddRoomType(RoomTypeViewModel model) { try { RoomType roomtype = new RoomType(); roomtype.Type = model.Type; roomtype.Capacity = model.Capacity; _context.RoomType.Add(roomtype); _context.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public ActionResult Edit(int id, RoomTypeViewModel model) { try { bool result = _roomTypeService.UpdateRoomType(model); if (result) { return(RedirectToAction(nameof(Index))); } throw new Exception(); } catch { ModelState.AddModelError(string.Empty, "Ooops! Something went wrong!"); return(View()); } }
public JsonResult CheckRoomTypeNameExist(string roomtypeName) { bool check = false; RoomTypeViewModel rtViewModel = new RoomTypeViewModel(); try { check = _rtRepo.CheckRoomTypeNameExist(roomtypeName); Logger.Debug("RoomType Controller CheckRoomTypeNameExist"); } catch (Exception ex) { Logger.Error("RoomType Controller - CheckRoomTypeNameExist" + ex.Message); } return(Json(check, JsonRequestBehavior.AllowGet)); }
public JsonResult Insert(RoomTypeViewModel rtViewModel) { try { Set_Date_Session(rtViewModel.RoomType); rtViewModel.RoomType.RoomTypeId = _rtRepo.Insert(rtViewModel.RoomType); rtViewModel.FriendlyMessage.Add(MessageStore.Get("RT01")); Logger.Debug("RoomType Controller Insert"); } catch (Exception ex) { rtViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01")); Logger.Error("RoomType Controller - Insert " + ex.Message); } return(Json(rtViewModel)); }
public JsonResult Update(RoomTypeViewModel rtViewModel) { try { Set_Date_Session(rtViewModel.RoomType); _rtRepo.Update(rtViewModel.RoomType); rtViewModel.FriendlyMessage.Add(MessageStore.Get("RT02")); Logger.Debug("RoomType Controller Update"); } catch (Exception ex) { rtViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01")); Logger.Error("RoomType Controller - Update " + ex.Message); } return(Json(rtViewModel)); }