public async Task <string> Login(User user) { var loginJson = JsonConvert.SerializeObject(user); var content = new StringContent(loginJson, Encoding.UTF8, "application/json"); var request = new HttpRequestMessage { RequestUri = new Uri(UrlName.GetAccountUrl()), Method = HttpMethod.Post, Content = content }; var response = _httpClient.SendAsync(request).Result; IEnumerable <string> headerValues; var isTokenExist = response.Headers.TryGetValues(TokenHeaderName, out headerValues); string token = null; if (isTokenExist) { token = headerValues.FirstOrDefault(); } return(token); }
public async Task <VacationDto> GetVacationByIdAsync(Guid id) { var vacation = await _vacationRepository.GetByIdAsync <Vacation>(id, UrlName.GetApiUrl()); var vacationDto = Mapper.Map <VacationDto>(vacation); return(vacationDto); }
public async Task <IEnumerable <VacationDto> > GetVacationAsync() { var vacations = await _vacationRepository.GetAsync <Vacation>(UrlName.GetApiUrl()); var vacationDtos = Mapper.Map <IEnumerable <VacationDto> >(vacations); return(vacationDtos); }
public override int GetHashCode() { unchecked { var hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (UrlName != null ? UrlName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ThumbnailImageUrl != null ? ThumbnailImageUrl.GetHashCode() : 0); return(hashCode); } }
// override object.Equals public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } EpStatus e = (EpStatus)obj; return(Id == e.Id && CssName.EqualsExT(e.CssName) && UrlName.EqualsExT(e.UrlName) && CnName.EqualsExT(e.CnName)); }
public string GetUrl() { if (!UrlName.IsEmpty()) { return(UrlName); } if (Notes != null && Notes.Contains("*")) { var url = Notes.Split('*').ElementAt(1); if (url.StartsWith("/")) { return(url); } } return(null); }
private void bUrl_Click(object sender, RoutedEventArgs e) { var cd = new CheckData(); var urlname = string.Empty; urlname = tbUrl.Text; if (cd.Check(urlname)) { var url = new UrlName(); var sl = new SetterLower(); var pdfcreator = new Pdfcreator(); url.SetUrlPdf(sl.SetLower(urlname)); pdfcreator.CreatePdfExample(url.GetUrlPdf(), pdfname.GetNamePdf()); MessageBox.Show("PDF created!"); } }
public async Task <IEnumerable <VacationDto> > FilterVacations(FilterEnum type) { var vacations = await _vacationRepository.GetAsync <Vacation>(UrlName.GetApiUrl()); switch (type) { case FilterEnum.Closed: { var result = Mapper.Map <IEnumerable <VacationDto> >(vacations.Where(x => x.VacationStatus == VacationStatus.Closed)); return(result); } case FilterEnum.Opened: return(Mapper.Map <IEnumerable <VacationDto> >(vacations.Where(x => x.VacationStatus != VacationStatus.Closed))); default: return(Mapper.Map <IEnumerable <VacationDto> >(vacations)); } }
public UserRepository() { _httpClient = new HttpClient { BaseAddress = new Uri(UrlName.GetAccountUrl()) }; }
public static UDT.WebUrls GetWebUrl(UrlName name) { List<string> names = new List<string>() { "課程計劃" }; return getUrl(names.ElementAt((int)name)); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { List <ValidationResult> result = new List <ValidationResult>(); if (!this.UrlName.IsValidUrlName()) { string fieldName = "UrlName"; string fieldDisplay = this.GetDisplayName("UrlName"); result.Add(new ValidationResult(fieldDisplay + " value of '" + this.UrlName + "' is invalid. You cannot use any of the following characters: " + UrlName.InvalidUrlNameCharacters(), new string[] { fieldName })); this.UrlName = this.UrlName.FixUrlName(); } if (this.DigitalDownload && string.IsNullOrWhiteSpace(this.DigitalDownloadFileName)) { HttpContext http = HttpContext.Current; if (http == null || http.Request.Files["DigitalDownloadFileName_File"] == null || http.Request.Files["DigitalDownloadFileName_File"].ContentLength == 0) { string dlCheckboxName = this.GetDisplayName("DigitalDownload"); string dlFileName = this.GetDisplayName("DigitalDownloadFileName"); result.Add(new ValidationResult(dlFileName + " is required when '" + dlCheckboxName + "' is checked.", new string[] { "DigitalDownloadFileName" })); } } if (this.RequestAQuote_Show && this.RequestAQuote_PageId == null) { string blankFieldName = "RequestAQuote_PageId"; string fieldDisplayBlank = this.GetDisplayName("RequestAQuote_PageId"); string fieldDisplayCheckbox = this.GetDisplayName("RequestAQuote_PageId"); result.Add(new ValidationResult("'" + fieldDisplayBlank + "' must be selected when the '" + fieldDisplayCheckbox + "' box is checked.", new string[] { blankFieldName })); } if (this.AvailableForPurchase && this.BaseUnitPrice == null) { string blankFieldName = "BaseUnitPrice"; string fieldDisplayBlank = this.GetDisplayName("BaseUnitPrice"); string fieldDisplayCheckbox = this.GetDisplayName("AvailableForPurchase"); result.Add(new ValidationResult("'" + fieldDisplayBlank + "' must be selected when the '" + fieldDisplayCheckbox + "' box is checked.", new string[] { blankFieldName })); } return(result); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { List <ValidationResult> result = new List <ValidationResult>(); if (!this.UrlName.IsValidUrlName()) { string fieldName = "UrlName"; string fieldDisplay = this.GetDisplayName("UrlName"); result.Add(new ValidationResult(fieldDisplay + " value of '" + this.UrlName + "' is invalid. You cannot use any of the following characters: " + UrlName.InvalidUrlNameCharacters(), new string[] { fieldName })); this.UrlName = this.UrlName.FixUrlName(); } if (this.RequestAQuote_Show && this.RequestAQuote_PageId == null) { string blankFieldName = "RequestAQuote_PageId"; string fieldDisplayBlank = this.GetDisplayName("RequestAQuote_PageId"); string fieldDisplayCheckbox = this.GetDisplayName("RequestAQuote_PageId"); result.Add(new ValidationResult("'" + fieldDisplayBlank + "' must be selected when the '" + fieldDisplayCheckbox + "' box is checked.", new string[] { blankFieldName })); } return(result); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { List <ValidationResult> result = new List <ValidationResult>(); string fieldName = "UrlName"; string fieldDisplay = null; if (!this.UrlName.IsValidUrlName()) { fieldName = "UrlName"; fieldDisplay = this.GetDisplayName("UrlName"); result.Add(new ValidationResult(fieldDisplay + " value of '" + this.UrlName + "' is invalid. You cannot use any of the following characters: " + UrlName.InvalidUrlNameCharacters(), new string[] { fieldName })); this.UrlName = this.UrlName.FixUrlName(); } return(result); }
public Task <bool> DeleteVacationByIdAsync(Guid id) { return(_vacationRepository.DeleteAsync <Vacation>(id, UrlName.GetApiUrl())); }
public Task <bool> UpdateVacationAsync(VacationDto entity) { var vacation = Mapper.Map <Vacation>(entity); return(_vacationRepository.UpdateAsync(vacation, UrlName.GetApiUrl())); }
public CommonApiRepository() { _httpClient = new HttpClient { BaseAddress = new Uri(UrlName.GetApiUrl()) }; }