public IActionResult AddElectric(ElectricDto model)
        {
            var building = model.MapTo <Electric>(mapper);

            if (ModelState.IsValid)
            {
                unitOfWork.GetRepository <Electric>().InsertAsync(building);
                unitOfWork.GetRepository <Electric>().SaveAsync();
                return(new ObjectResult("Model added successfully!"));
            }
            return(new ObjectResult("Model added unsuccessfully!"));
        }
        public async Task <IActionResult> UpdateElectric(Guid id, ElectricDto model)
        {
            var electric    = model.MapTo <Electric>(mapper);
            var newElectric = await unitOfWork.GetRepository <Electric>().GetByIdAsync(id);

            if (ModelState.IsValid && id == model.Id)
            {
                unitOfWork.GetRepository <Electric>().Update(newElectric);
                unitOfWork.GetRepository <Electric>().SaveAsync();
                return(new ObjectResult("Model updated successfully!"));
            }
            return(new ObjectResult("Model updated unsuccessfully!"));
        }
Example #3
0
        public async Task <ActionResult> UpdateElectric(Guid id, ElectricDto model)
        {
            var response = await RestQuery.ExecuteAsync <List <ElectricDto> >("http://localhost:57770/", $"UpdateElectric/{id}", Method.PUT, model);

            return(Json(response));
        }
Example #4
0
        public async Task <ActionResult> AddElectric(ElectricDto model)
        {
            var response = await RestQuery.ExecuteAsync <ElectricDto>("http://localhost:57770/", "AddElectric", Method.POST, model);

            return(Json(response));
        }