private ResultDto InsertUpdateVillage(VillageDto village) { ResultDto resultDto = new ResultDto(); string obectName = "village"; try { ObjectParameter paramVillageID = new ObjectParameter("VillageId", village.VillageID); ObjectParameter paramVillageCode = new ObjectParameter("VillageCode", string.Empty); int count = _dbContext.uspVillageInsertUpdate(paramVillageID, village.Village, village.TEVillageName, village.ClusterID, village.UserID, paramVillageCode); resultDto.ObjectId = (int)paramVillageID.Value; resultDto.ObjectCode = string.IsNullOrEmpty((string)paramVillageCode.Value) ? village.VillageCode : (string)paramVillageCode.Value; if (resultDto.ObjectId > 0) { resultDto.Message = string.Format("{0} details saved successfully with code : {1}", obectName, resultDto.ObjectCode); } else if (resultDto.ObjectId == -1) { resultDto.Message = string.Format("Error occured while generating {0} code", obectName); } else { resultDto.Message = string.Format("Error occured while saving {0} details", obectName); } } catch (Exception) { resultDto.Message = string.Format("Service layer error occured while saving the {0} details", obectName); resultDto.ObjectId = -98; } return(resultDto); }
public VillageDto GetByID(int villageId) { VillageDto objVillageDto = new VillageDto(); List <VillageDto> lstvillageDto = new List <VillageDto>(); List <uspVillageGetById_Result> lstuspVillageGetById_Result = _dbContext.uspVillageGetById(villageId).ToList(); objVillageDto = Mapper.Map <uspVillageGetById_Result, VillageDto>(lstuspVillageGetById_Result.FirstOrDefault()); return(objVillageDto); }
public async Task AddVillageAsync(VillageDto village) { var villageToBeSaved = new Village { Name = village.Name, TalukaId = village.TalukaId }; context.Villages.Add(villageToBeSaved); await context.SaveChangesAsync(); village.Id = villageToBeSaved.Id; }
public async Task <IActionResult> Post([FromBody] VillageDto village) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await villageRepository.AddVillageAsync(village); return(Created("contextapi/village", village)); }
public List <VillageDto> GetAll() { List <VillageDto> lstVillageDto = new List <VillageDto>(); List <uspVillageGetAll_Result> lstuspVillageGetAll_Result = _dbContext.uspVillageGetAll().ToList(); foreach (var Village in lstuspVillageGetAll_Result) { VillageDto VillageDto = Mapper.Map <uspVillageGetAll_Result, VillageDto>(Village); lstVillageDto.Add(VillageDto); } return(lstVillageDto); }
public ActionResult CreateVillage(string Id) { int villageId = DecryptQueryString(Id); VillageDto villageDto = new VillageDto(); if (villageId > 0) { villageDto = _villageService.GetByID(villageId); } VillageModel objVillage = Mapper.Map <VillageDto, VillageModel>(villageDto); LoadDropDowns(objVillage.StateID, objVillage.DistrictID, objVillage.MandalID, objVillage.ClusterID); return(View(objVillage)); }
public ResultDto Update(VillageDto Village) { return(InsertUpdateVillage(Village)); }