public ActionResultDTO UpdateAlternateServerIp(AlternateServerIpEntity alternateServerIp) { var r = GetAlternateServerIp(alternateServerIp.Id); if (r == null) { return new ActionResultDTO { ErrorMessage = "Alternate Server Ip Not Found", Id = 0 } } ; var validationResult = ValidateAlternateServerIp(alternateServerIp, false); var actionResult = new ActionResultDTO(); if (validationResult.Success) { _uow.AlternateServerIpRepository.Update(alternateServerIp, alternateServerIp.Id); _uow.Save(); actionResult.Success = true; actionResult.Id = alternateServerIp.Id; } return(actionResult); }
public ActionResultDTO Put(int id, AlternateServerIpEntity alternateServerIp) { alternateServerIp.Id = id; var result = _alternateServerIpServices.UpdateAlternateServerIp(alternateServerIp); if (result == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(result); }
protected void Insert(object sender, EventArgs e) { RequiresAuthorization(AuthorizationStrings.UpdateAdmin); var gvRow = (GridViewRow)(sender as Control).Parent.Parent; var alternateIp = new AlternateServerIpEntity { Ip = ((TextBox)gvRow.FindControl("txtIpAdd")).Text, ApiUrl = ((TextBox)gvRow.FindControl("txtApiAdd")).Text }; Call.AlternateServerIpApi.Post(alternateIp); BindGrid(); }
public ActionResultDTO Put(int id, AlternateServerIpEntity tObject) { Request.Method = Method.PUT; Request.AddJsonBody(tObject); Request.Resource = string.Format("api/{0}/Put/{1}", Resource, id); var response = _apiRequest.Execute <ActionResultDTO>(Request); if (response.Id == 0) { response.Success = false; } return(response); }
protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e) { RequiresAuthorization(AuthorizationStrings.UpdateAdmin); var gvRow = gvIps.Rows[e.RowIndex]; var alternateIp = new AlternateServerIpEntity { Id = Convert.ToInt32(gvIps.DataKeys[e.RowIndex].Values[0]), Ip = ((TextBox)gvRow.FindControl("txtIp")).Text, ApiUrl = ((TextBox)gvRow.FindControl("txtApi")).Text }; Call.AlternateServerIpApi.Put(alternateIp.Id, alternateIp); gvIps.EditIndex = -1; this.BindGrid(); }
private ValidationResultDTO ValidateAlternateServerIp(AlternateServerIpEntity alternateServerIp, bool isNewAlternateServerIp) { var validationResult = new ValidationResultDTO { Success = true }; if (!alternateServerIp.ApiUrl.Trim().EndsWith("/")) { alternateServerIp.ApiUrl += "/"; } if (string.IsNullOrEmpty(alternateServerIp.Ip) || string.IsNullOrEmpty(alternateServerIp.ApiUrl)) { validationResult.Success = false; validationResult.ErrorMessage = "Empty Values Are Not Valid"; return(validationResult); } if (isNewAlternateServerIp) { if (_uow.AlternateServerIpRepository.Exists(h => h.Ip == alternateServerIp.Ip)) { validationResult.Success = false; validationResult.ErrorMessage = "This Server Ip Already Exists"; return(validationResult); } } else { var originalAlternateServerIp = _uow.AlternateServerIpRepository.GetById(alternateServerIp.Id); if (originalAlternateServerIp.Ip != alternateServerIp.Ip) { if (_uow.AlternateServerIpRepository.Exists(h => h.Ip == alternateServerIp.Ip)) { validationResult.Success = false; validationResult.ErrorMessage = "This Server Ip Already Exists"; return(validationResult); } } } return(validationResult); }
public ActionResultDTO AddAlternateServerIp(AlternateServerIpEntity alternateServerIp) { var validationResult = ValidateAlternateServerIp(alternateServerIp, true); var actionResult = new ActionResultDTO(); if (validationResult.Success) { _uow.AlternateServerIpRepository.Insert(alternateServerIp); _uow.Save(); actionResult.Success = true; actionResult.Id = alternateServerIp.Id; } else { actionResult.ErrorMessage = validationResult.ErrorMessage; } return(actionResult); }
public ActionResultDTO Post(AlternateServerIpEntity alternateServerIp) { return(_alternateServerIpServices.AddAlternateServerIp(alternateServerIp)); }