コード例 #1
0
        public IActionResult AddBuilding(TypeOfRoomDto model)
        {
            var type = model.MapTo <Type_of_room>(mapper);

            if (ModelState.IsValid)
            {
                unitOfWork.GetRepository <Type_of_room>().InsertAsync(type);
                unitOfWork.SaveAsync();
                return(new ObjectResult("Model added successfully!"));
            }
            return(new ObjectResult("Model added unsuccessfully!"));
        }
コード例 #2
0
        public async Task <IActionResult> UpdateBuilding(Guid id, TypeOfRoomDto model)
        {
            var type    = model.MapTo <Type_of_room>(mapper);
            var newType = await unitOfWork.GetRepository <Type_of_room>().GetByIdAsync(id);

            newType.Name = type.Name;

            if (ModelState.IsValid && id == model.Id)
            {
                unitOfWork.GetRepository <Type_of_room>().Update(newType);
                unitOfWork.GetRepository <Type_of_room>().SaveAsync();
                return(new ObjectResult("Model updated successfully!"));
            }
            return(new ObjectResult("Model updated unsuccessfully!"));
        }
コード例 #3
0
        public async Task <ActionResult> UpdateType(Guid id, TypeOfRoomDto type)
        {
            var response = await RestQuery.ExecuteAsync <string>("http://localhost:57770/", $"UpdateType/{id}", Method.PUT, type);

            return(Json(response));
        }
コード例 #4
0
        public async Task <ActionResult> AddType(TypeOfRoomDto type)
        {
            var response = await RestQuery.ExecuteAsync <string>("http://localhost:57770/", "AddType", Method.POST, type);

            return(Json(response));
        }