public async Task <StateDTO> CreateAsync(StateDTO dto) { var model = _mapper.Map <State>(dto); await _unitOfWork.StateRepository.AddAsync(model); await _unitOfWork.SaveAsync(); return(_mapper.Map <StateDTO>(model)); }
/* * Gibt den neuen Status zurück (schmeißt eine Exception wenn der Status nicht geändert werden kann). * Updated Issue und alle abhängigen Issues */ public async Task <StateDTO> UpdateState(Issue issue, StateDTO newState) { if (issue.StateId == newState.Id) { return(newState); } var state = await _updateStateHandler.HandleStateUpdate(issue, await _stateService.GetState(issue.ProjectId, issue.StateId), newState); return(state); }
public StateDTO ToDTO(StateEntity entity) { StateDTO dto = new StateDTO(); dto.CreateTime = entity.CreateTime; dto.Description = entity.Description; dto.Id = entity.Id; dto.Name = entity.Name; return(dto); }
public IssueDTO(Issue issue, StateDTO state, ProjectDTO project, UserDTO client, UserDTO author) { Id = issue.Id; IssueDetail = issue.IssueDetail; State = state; Project = project; Client = client; Author = author; }
public JsonResult Editar(string descripcion, string catalogoId, string itemId) { string result = "duplicate"; switch (catalogoId) { case "m": if (!cliente.GetStates().Any(m => m.Name.ToLower() == descripcion.ToLower())) { StateDTO state = new StateDTO(); state.Name = descripcion; state.Id = Int32.Parse(itemId); cliente.UpdateState(state); result = "success"; } break; case "p": if (!cliente.GetMonths().Any(m => m.Description.ToLower() == descripcion.ToLower())) { MonthDTO month = new MonthDTO(); month.Description = descripcion; month.Id = Int32.Parse(itemId); cliente.UpdateMonth(month); result = "success"; } break; case "n": if (!cliente.GetStatus().Any(m => m.Description.ToLower() == descripcion.ToLower())) { StatusDTO status = new StatusDTO(); status.Description = descripcion; status.Id = Int32.Parse(itemId); cliente.UpdateStatus(status); result = "success"; } break; case "c": if (!cliente.GetYears().Any(m => m.Description.ToLower() == descripcion.ToLower())) { YearDTO year = new YearDTO(); year.Description = descripcion; year.Id = Int32.Parse(itemId); cliente.UpdateYear(year); result = "success"; } break; } return(new JsonResult { Data = new { Result = result } }); }
public JsonResult GetStateList()//Return State List { DbSet <tblState> States = _unitOfWork.Projects.GetStatesList(); List <StateDTO> StateDTOList = new List <StateDTO>(); foreach (tblState ts in States) { StateDTO sd = Mapper.Map <tblState, StateDTO>(ts); StateDTOList.Add(sd); } _unitOfWork.Complete(); return(Json(StateDTOList, JsonRequestBehavior.AllowGet)); }
public async Task UpdateState(int stateId, StateDTO state) { var states = await _stateRepo.GetAsync(stateId); if (states == null) { throw await _serviceHelper.GetExceptionAsync(ErrorConstants.STATE_NOT_EXIST); } states.Name = state.Name.Trim(); await _unitOfWork.SaveChangesAsync(); }
public void UpdateState(StateDTO dto) { var b = new ParamDAO(); if (dto.Id > 0) { b.UpdateState(dto, true); } else { b.UpdateState(dto, false); } }
public static List <StateDTO> ToStateDTO(List <StateBO> list) { List <StateDTO> DTOList = new List <StateDTO>(); foreach (var item in list) { StateDTO StateDTO = new StateDTO(); StateDTO.StateCode = item.StateCode; StateDTO.StateId = item.StateId; StateDTO.StateName = item.StateName; DTOList.Add(StateDTO); } return(DTOList); }
//Get list of all states using a countryId public IEnumerable<StateDTO> Get(int countryId) { IList<StateDTO> states = new List<StateDTO>(); for (var i = 0; i <= 5; i++) { var state = new StateDTO { StateId = i, CountryId = countryId, StateName = "State" + i }; states.Add(state); } return states; }
public ActionResult Edit(StateDTO objStateMasterDTO) { objStateMasterDTO.ModifiedBy = Convert.ToInt32(Session["UserID"]); DateTime timeUtc = System.DateTime.UtcNow; TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"); DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, cstZone); objStateMasterDTO.ModifiedDate = cstTime; objIStateMaster.UpdateState(objStateMasterDTO); TempData["MessageUpdate"] = "State Updated Successfully."; return(RedirectToAction("Details")); }
public async Task <IActionResult> ChangeState([FromBody] StateDTO body) { foreach (SafetyDoc item in data.SafetyDocs) { if (item.Id == body.Id) { item.Status = body.Status; data.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified; break; } } await data.SaveChangesAsync(); return(Ok()); }
public HttpResponseMessage GetState(int StateId) { try { Claims claims = new Claims().Values(); StateDTO state = _StateDao.Get(StateId); return(Request.CreateResponse(HttpStatusCode.OK, state)); } catch (System.Exception e) { LogManager.Error("Erro ao consultar Estado", e); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } }
public void InsertState(StateDTO state) { con.Open(); var para = new DynamicParameters(); para.Add("@StateId", state.StateId); // Normal Parameters para.Add("@StateName", state.StateName); para.Add("@CreatedDate", state.CreatedDate); para.Add("@CreatedBy", state.CreatedBy); para.Add("@ModifiedDate", state.ModifiedDate); para.Add("@ModifiedBy", state.ModifiedBy); para.Add("@DeleteStatus", "ACTIVE"); var value = con.Query <int>("SP_Insert_Update_StateMaster", para, null, true, 0, CommandType.StoredProcedure); con.Close(); }
public async Task UpdateClients() { var stateDTO = new StateDTO { Objects = World.Instance.GetObjects(), DeadPlayersIds = World.Instance.GetDeadPlayersIds(), AlivePlayersIds = World.Instance.GetAlivePlayersIds(), PlayerScores = World.Instance.GetPlayerScores() }; await Clients.All.SendAsync("StateUpdate", JsonConvert.SerializeObject(stateDTO, typeof(StateDTO), new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto })); }
protected void grdState_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (Page.IsValid) { //To update state StateDTO stateDetails = new StateDTO(); stateDetails = ESalesUnityContainer.Container.Resolve<ILocationService>() .GetStateByStateId(Convert.ToInt32(grdState.DataKeys[e.RowIndex].Value)); stateDetails.State_Name = ((TextBox)grdState.Rows[e.RowIndex].FindControl("txtState")).Text; stateDetails.State_LastUpdatedDate = DateTime.Now; stateDetails.State_CreatedBy = GetCurrentUserId(); int stateId = ESalesUnityContainer.Container.Resolve<ILocationService>().UpdateState(stateDetails); ucMessageBoxForGrid.ShowMessage(Messages.StateUpdatedSuccessfully); } }
public async Task <ActionResult <State> > SaveState([FromBody] StateDTO _StateS) { State _State = _StateS; try { // DTO_NumeracionSAR _liNumeracionSAR = new DTO_NumeracionSAR(); string baseadress = config.Value.urlbase; HttpClient _client = new HttpClient(); _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token")); var result = await _client.GetAsync(baseadress + "api/State/GetStateById/" + _State.Id); string valorrespuesta = ""; _State.FechaModificacion = DateTime.Now; _State.Usuariomodificacion = HttpContext.Session.GetString("user"); if (result.IsSuccessStatusCode) { valorrespuesta = await(result.Content.ReadAsStringAsync()); _State = JsonConvert.DeserializeObject <StateDTO>(valorrespuesta); } if (_State == null) { _State = new Models.State(); } if (_StateS.Id == 0) { //_CAI.FechaCreacion = DateTime.Now; //_CAI.UsuarioCreacion = HttpContext.Session.GetString("user"); var insertresult = await Insert(_StateS); } else { _StateS.Usuariocreacion = _State.Usuariocreacion; _StateS.FechaCreacion = _State.FechaCreacion; var updateresult = await Update(_State.Id, _StateS); } } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); throw ex; } return(Json(_State)); }
public void UpdateState(StateDTO state) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Mystring"].ToString())) { con.Open(); var para = new DynamicParameters(); para.Add("@StateId", state.StateId); // Normal Parameters para.Add("@StateName", state.StateName); para.Add("@CreatedDate", state.CreatedDate); para.Add("@CreatedBy", state.CreatedBy); para.Add("@ModifiedDate", state.ModifiedDate); para.Add("@ModifiedBy", state.ModifiedBy); para.Add("@DeleteStatus", state.DeleteStatus); var value = con.Query <int>("SP_Insert_Update_StateMaster", para, null, true, 0, CommandType.StoredProcedure); con.Close(); } }
protected void grdState_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals(Globals.GridCommandEvents.ADDNEW)) { if (Page.IsValid) { GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer); StateDTO stateDetails = new StateDTO(); stateDetails.State_Name = ((TextBox)row.FindControl("txtNewState")).Text; stateDetails.State_CreatedDate = DateTime.Now; stateDetails.State_CreatedBy = GetCurrentUserId(); int stateId = ESalesUnityContainer.Container.Resolve<ILocationService>().SaveState(stateDetails); ucMessageBoxForGrid.ShowMessage(Messages.StateSavedSuccessfully); } } }
public async Task UpdateState(ObjectId projectId, ObjectId stateId, StateDTO stateDTO) { var project = await _projectRepository.GetAsync(projectId); if (project is null) { throw new HttpStatusException(404, "Project not found"); } await AuthorizeEmployeeAndLeaderRolesAsync(project); if (stateDTO.Id != stateId) { throw new HttpStatusException(400, "Cannot Update: State ID does not match"); } await _projectRepository.UpdateState(projectId, stateId, stateDTO.Name, stateDTO.Phase); }
public StateDTO PutState(int id, [FromBody] StateDTO state) { var editState = dbm.FindStateByID(id); bool changesMade = false; if (editState.Description != state.Description) { editState.Description = state.Description; changesMade = true; } if (changesMade) { db.SaveChanges(); } return(converter.StateToDTO(editState)); }
[NonAction] // if Method is not Action method then use NonAction public List <StateDTO> BindListState() { List <StateDTO> liststate = new List <StateDTO>() { new StateDTO { StateId = 0, StateName = "Select" } }; foreach (var item in objStateMaster.GetStates()) { StateDTO st = new StateDTO(); st.StateId = item.StateId; st.StateName = item.StateName; liststate.Add(st); } return(liststate); }
public IssueDTODetailed(ObjectId id, StateDTO state, ProjectDTO project, UserDTO client, UserDTO author, IList <UserDTO>?assignedUsers, IList <IssueConversationDTO>?conversationItems, IList <IssueTimeSheetDTO>?timeSheets, IssueDetail issueDetail, IssueDTO?parentIssue, IList <IssueDTO>?childrenIssues, IList <IssueDTO>?predecessorIssues, IList <IssueDTO>?successorIssues) { Id = id; State = state; Project = project; Client = client; Author = author; AssignedUsers = assignedUsers; ConversationItems = conversationItems; TimeSheets = timeSheets; IssueDetail = issueDetail; ParentIssue = parentIssue; ChildrenIssues = childrenIssues; PredecessorIssues = predecessorIssues; SuccessorIssues = successorIssues; }
public async Task <IActionResult> Post([FromBody] StateDTO stateData) { try { if (ModelState.IsValid) { var newState = _mapper.Map <StateDTO, State>(stateData); newState.CreatedDate = DateTimeOffset.UtcNow; await _repository.CreateAsync(newState); return(Ok(newState)); } return(Json(ModelState)); } catch (Exception ex) { return(BadRequest(_errorHandler.JsonErrorMessage((int)HttpStatusCode.BadRequest, ex.Message + ex.InnerException.Message))); } }
public async Task <StateDTO> UpdateAsync(StateDTO stateDTO) { var model = _mapper.Map <State>(await GetAsync((int)stateDTO.Id)); if (model.IsFixed) { throw new ConstraintException("Current state can not be edited"); } if (stateDTO.IsFixed) { throw new ArgumentException("Incorrect model"); } ; model.TransName = stateDTO.TransName; _unitOfWork.StateRepository.Update(model); await _unitOfWork.SaveAsync(); return(_mapper.Map <StateDTO>(model)); }
/// <summary> /// Update State Record /// </summary> /// <param name="obj"></param> /// <param name="id"></param> /// <returns></returns> public async Task <string> UpdateState(StateDTO obj, int id) { string status = ""; try { //Check if record exist not as same id var checkexist = await _context.BtState.AnyAsync(x => x.StateId != id && (x.Name == obj.name)); if (checkexist == false) { var state = await _context.BtState.FirstOrDefaultAsync(x => x.StateId == id); state.Name = obj.name; //state.CountryCode = obj.countrycode; state.ModifiedBy = _authUser.Name; state.LastModified = DateTime.Now; if (await _context.SaveChangesAsync() > 0) { status = "1"; return(status); } else { status = ResponseErrorMessageUtility.RecordNotSaved; return(status); } } status = string.Format(ResponseErrorMessageUtility.RecordExistBefore, obj.name); return(status); } catch (Exception ex) { _logger.LogError(ex.Message); status = ResponseErrorMessageUtility.RecordNotSaved; return(status); } }
public async Task AddState(StateDTO stateDto) { if (!await IsValidRegion(stateDto.RegionId)) { throw await _serviceHelper.GetExceptionAsync(ErrorConstants.REGION_NOT_EXIST); } stateDto.Name = stateDto.Name.Trim(); if (await _stateRepo.ExistAsync(v => v.Name == stateDto.Name)) { throw await _serviceHelper.GetExceptionAsync(ErrorConstants.STATE_EXIST); } _stateRepo.Insert(new State { Id = stateDto.Id, Name = stateDto.Name, RegionId = stateDto.RegionId }); await _unitOfWork.SaveChangesAsync(); }
public void Method(PaperDTO objpaper) { ModelState.Remove("ListState"); List <StateDTO> liststate = new List <StateDTO>(); liststate = new List <StateDTO>() { new StateDTO { StateId = 0, StateName = "Select" } }; foreach (var item in objState.GetStates()) { StateDTO sm = new StateDTO(); sm.StateId = item.StateId; sm.StateName = item.StateName; liststate.Add(sm); } objpaper.ListState = liststate; }
public async Task <StateDTO> CreateStateAsync(ObjectId projectId, StateDTO requestedState) { var project = await _projectRepository.GetAsync(projectId); if (project is null) { throw new HttpStatusException(404, "Project not found"); } await AuthorizeEmployeeAndLeaderRolesAsync(project); var state = new State() { Id = ObjectId.GenerateNewId(), Phase = requestedState.Phase, Name = requestedState.Name, UserGenerated = true, }; await _projectRepository.AddState(projectId, state); return(new StateDTO(state)); }
public void UpdateState(StateDTO state, bool editar) { using (SEDESOLEntities entities = new SEDESOLEntities()) { if (editar) { STATE existente = entities.STATEs.FirstOrDefault(v => v.Id == state.Id); if (existente != null) { existente.Name = state.Name; entities.SaveChanges(); } } else { STATE nueva = new STATE(); nueva.Name = state.Name; nueva.IsActive = true; nueva.Abbreviation = string.Empty; entities.STATEs.Add(nueva); entities.SaveChanges(); } } }
public ActionResult Create(StateDTO objStateMasterDTO) { if (ModelState.IsValid) { objStateMasterDTO.CreatedBy = Convert.ToInt32(Session["UserID"]); DateTime timeUtc = System.DateTime.UtcNow; TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"); DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, cstZone); objStateMasterDTO.CreatedDate = cstTime; objIStateMaster.InsertState(objStateMasterDTO); TempData["MessageRegistration"] = "Data Saved Successfully!"; return(RedirectToAction("Create")); } else { // TempData["MessageRegistration"] = "Please enter Division Name!"; ModelState.AddModelError("", "Please enter State Name "); } // ModelState.Remove("DivisionName"); return(View(objStateMasterDTO)); }
public ActionResult Create() { CityDTO objCM = new CityDTO(); List <StateDTO> liststate = new List <StateDTO>(); liststate = new List <StateDTO>() { new StateDTO { StateId = 0, StateName = "Select" } }; foreach (var item in objState.GetStates()) { StateDTO st = new StateDTO(); st.StateId = item.StateId; st.StateName = item.StateName; liststate.Add(st); } objCM.ListState = liststate; return(View(objCM)); }