public async Task <int> Add(RoomTypeRequest request) { var check = await _repository.ExecuteNonQuery("RoomTypeInsert", new { Name = request.Name, Price = request.Price, Description = request.Description, CreatedUserId = 1 }); return(check); }
public async Task <int> Update(RoomTypeRequest request) { var check = await _repository.ExecuteNonQuery("RoomTypeUpdate", new { Id = request.Id, Name = request.Name, Price = request.Price, Description = request.Description, ModifiedUserId = 2 }); return(check); }
public ActionResult <RoomType> Create(RoomTypeRequest item) { var roomType = new RoomType(); roomType.Code = item.Code.ToUpper(); roomType.Name = item.Name; roomType.Price = item.UnitPrice; db.Add(roomType); db.SaveChanges(); return(CreatedAtAction(nameof(GetByCode), new { code = roomType.Code }, roomType)); }
public List <RoomType> GetListRoomType(RoomTypeRequest request) { var param = new SqlServerParameter(); param.Add_Parameter("@_IsActive", request.IsActive); param.Add_Parameter("@_PageSize", request.PageSize); param.Add_Parameter("@_PageIndex", request.PageIndex); var data = _database.ExecuteToTable("RoomType_GetList", param, ExecuteTypeEnum.StoredProcedure); if (data != null && data.Rows.Count > 0) { return(SqlMapper <RoomType> .Map(data)); } return(new List <RoomType>()); }
public GridModel <Contact> GetListContact(RoomTypeRequest request) { var param = new SqlServerParameter(); param.Add_Parameter("@_PageSize", request.PageSize); param.Add_Parameter("@_PageIndex", request.PageIndex); var data = _database.ExecuteToDataset("Contact_GetList", param, ExecuteTypeEnum.StoredProcedure); if (data != null && data.Tables.Count == 2) { return(new GridModel <Contact> { Data = SqlMapper <Contact> .Map(data.Tables[0]), TotalRecord = (int)data.Tables[1].Rows[0]["TotalRecord"] }); } return(new GridModel <Contact>()); }
public ActionResult Update(string code, RoomTypeRequest item) { if (code != item.Code) { return(BadRequest()); } var roomType = db.RoomTypes.Find(code); if (roomType == null) { return(NotFound(new ProblemDetails { Title = $"Room type {code} not found" })); } roomType.Name = item.Name; roomType.Price = item.UnitPrice; db.SaveChanges(); return(NoContent()); }