/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 25, Configuration.FieldSeparator), Id, SequenceNumberTestObservationMasterFile.HasValue ? SequenceNumberTestObservationMasterFile.Value.ToString(Consts.NumericFormat, culture) : null, UniversalServiceIdentifier?.ToDelimitedString(), CategoryIdentifier != null ? string.Join(Configuration.FieldRepeatSeparator, CategoryIdentifier.Select(x => x.ToDelimitedString())) : null, CategoryDescription?.ToDelimitedString(), CategorySynonym != null ? string.Join(Configuration.FieldRepeatSeparator, CategorySynonym) : null, EffectiveTestServiceStartDateTime.HasValue ? EffectiveTestServiceStartDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, EffectiveTestServiceEndDateTime.HasValue ? EffectiveTestServiceEndDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, TestServiceDefaultDurationQuantity.HasValue ? TestServiceDefaultDurationQuantity.Value.ToString(Consts.NumericFormat, culture) : null, TestServiceDefaultDurationUnits?.ToDelimitedString(), TestServiceDefaultFrequency, ConsentIndicator, ConsentIdentifier?.ToDelimitedString(), ConsentEffectiveStartDateTime.HasValue ? ConsentEffectiveStartDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, ConsentEffectiveEndDateTime.HasValue ? ConsentEffectiveEndDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, ConsentIntervalQuantity.HasValue ? ConsentIntervalQuantity.Value.ToString(Consts.NumericFormat, culture) : null, ConsentIntervalUnits?.ToDelimitedString(), ConsentWaitingPeriodQuantity.HasValue ? ConsentWaitingPeriodQuantity.Value.ToString(Consts.NumericFormat, culture) : null, ConsentWaitingPeriodUnits?.ToDelimitedString(), EffectiveDateTimeOfChange.HasValue ? EffectiveDateTimeOfChange.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, EnteredBy?.ToDelimitedString(), OrderableAtLocation != null ? string.Join(Configuration.FieldRepeatSeparator, OrderableAtLocation.Select(x => x.ToDelimitedString())) : null, FormularyStatus, SpecialOrderIndicator, PrimaryKeyValueCdm != null ? string.Join(Configuration.FieldRepeatSeparator, PrimaryKeyValueCdm.Select(x => x.ToDelimitedString())) : null ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
public IHttpActionResult PutCategoryDescription(int id, CategoryDescription categoryDescription) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != categoryDescription.ID) { return(BadRequest()); } db.Entry(categoryDescription).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CategoryDescriptionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public CategoryManegerDTO GetCategoryManagerById(long categoryId) { CategoryManegerDTO categoryManegerDTO = new CategoryManegerDTO(); Category category = unitOfWork.CategoryRepository.GetByID(categoryId); CategoryDescription arabicCategoryDescription = category.CategoryDescriptions.Where(c => c.LanguageId == Utils.getLanguage(Langs.Arabic)).FirstOrDefault(); categoryManegerDTO.ArabicName = arabicCategoryDescription.Name; categoryManegerDTO.ArabicDescription = arabicCategoryDescription.Description; categoryManegerDTO.ParentId = category.ParentId == null ? 0 : category.ParentId.Value; categoryManegerDTO.ArabicMetaDescription = arabicCategoryDescription.MetaDescription; CategoryDescription englishCategoryDescription = category.CategoryDescriptions.Where(c => c.LanguageId == Utils.getLanguage(Langs.English)).FirstOrDefault(); categoryManegerDTO.EnglishName = englishCategoryDescription.Name; categoryManegerDTO.EnglishMetaDescription = englishCategoryDescription.MetaDescription; categoryManegerDTO.EnglishDescription = englishCategoryDescription.Description; categoryManegerDTO.Id = categoryId; categoryManegerDTO.ImageUrl = category.ImageUrl == "" ? DefaultImages.Category : category.ImageUrl; categoryManegerDTO.ImageThumb = category.ImageThumb == "" ? DefaultImages.Category : category.ImageThumb; categoryManegerDTO.BannerImage = category.Banner == "" ? DefaultImages.Banner : category.Banner; categoryManegerDTO.SortOrder = category.SortOrder; categoryManegerDTO.Status = category.Status; categoryManegerDTO.DateCreation = category.DateAdded == null ? DateTime.Now : category.DateAdded.Value; categoryManegerDTO.DateCreation = category.DateModified == null ? DateTime.Now : category.DateModified.Value; categoryManegerDTO.ArabicPath = GetCategoryPath(categoryManegerDTO.EnglishName, Langs.Arabic).PathStr; categoryManegerDTO.EnglishPath = GetCategoryPath(categoryManegerDTO.EnglishName, Langs.English).PathStr; return(categoryManegerDTO); }
public void CreateRubric(List <CategoryModel> categories, List <DescriptionModel> descriptions) { var allDescriptions = new List <Description>(); var allCategories = new List <Category>(); var index = 0; var catInDb = new Category(); var newCategoryDescription = new CategoryDescription(); foreach (var cat in categories) { var bindedCategory = new Category { CatName = cat.Name }; // Create a new category in the db _rubricCreatorRepository.AddCategory(bindedCategory); allCategories.Add(bindedCategory); // Retrieve this category back catInDb = GetCategory(bindedCategory); } foreach (var desc in descriptions) { var newDescription = new Description(); newDescription.Name = desc.Description; // Create a new description _rubricCreatorRepository.AddDescription(newDescription); // Find the description in the db var descriptionInDb = _rubricCreatorRepository.FindDescription(newDescription); allDescriptions.Add(descriptionInDb); index++; if (index == 4) { var cat = allCategories.First(); foreach (var item in allDescriptions) { newCategoryDescription.CategoryId = cat.Id; newCategoryDescription.DescriptionId = item.Id; // Create a new CategoryDescription in the db _rubricCreatorRepository.AddCategoryDescription(newCategoryDescription); newCategoryDescription = new CategoryDescription(); } index = 0; allCategories.RemoveAt(0); allDescriptions = new List <Description>(); } } }
public long GetCategoryIdByName(string categoryName, Langs l) { long languageId = Utils.getLanguage(l); CategoryDescription categoryDescription = unitOfWork.CategoryDescriptionRepository.Get(op => op.LanguageId == (long)Langs.English).AsEnumerable().Where(op => (op.Name == categoryName || Utils.GenerateSlug(op.Name) == categoryName)).FirstOrDefault(); return(categoryDescription.CategoryId); }
public Category(CategoryId id, CategoryDescription description) { Description = description; Id = id; CategoryCreated categoryCreated = new(id.Value, description.Name, description.Description); base.Record(categoryCreated); }
private string GetCategoryNameById(long categoryId, Langs l) { long languageId = Utils.getLanguage(l); CategoryDescription categoryDescription = unitOfWork.CategoryDescriptionRepository.Get(op => op.LanguageId == (long)Langs.English && op.CategoryId == categoryId).FirstOrDefault(); return(categoryDescription.Name); }
public async Task Execute(CategoryId id, CategoryDescription description) { Category category = await _categoryFinder.Execute(id); await _categoryRepository.DeleteAsync(category).ConfigureAwait(false); await _categoryRepository.SaveChangesAsync().ConfigureAwait(false); await _eventBus.Publish(category.PullDomainEvents()); }
public IHttpActionResult GetCategoryDescription(int id) { CategoryDescription categoryDescription = db.CategoryDescriptions.Find(id); if (categoryDescription == null) { return(NotFound()); } return(Ok(categoryDescription)); }
public IHttpActionResult PostCategoryDescription(CategoryDescription categoryDescription) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CategoryDescriptions.Add(categoryDescription); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = categoryDescription.ID }, categoryDescription)); }
public IHttpActionResult DeleteCategoryDescription(int id) { CategoryDescription categoryDescription = db.CategoryDescriptions.Find(id); if (categoryDescription == null) { return(NotFound()); } db.CategoryDescriptions.Remove(categoryDescription); db.SaveChanges(); return(Ok(categoryDescription)); }
public bool Equals(DestinyDerivedItemCategoryDefinition input) { if (input == null) { return(false); } return (( CategoryDescription == input.CategoryDescription || (CategoryDescription != null && CategoryDescription.Equals(input.CategoryDescription)) ) && ( Items == input.Items || (Items != null && Items.SequenceEqual(input.Items)) )); }
public OperationDetails AddCategory(CategoryManegerDTO categoryManegerDTO) { Category category = new Category(); category.ImageUrl = categoryManegerDTO.ImageUrl == "" ? DefaultImages.Category : categoryManegerDTO.ImageUrl; category.ImageThumb = categoryManegerDTO.ImageThumb == "" ? DefaultImages.Category : categoryManegerDTO.ImageThumb; category.Banner = categoryManegerDTO.BannerImage == "" ? DefaultImages.Banner : categoryManegerDTO.BannerImage; category.SortOrder = categoryManegerDTO.SortOrder; category.Status = categoryManegerDTO.Status; category.DateModified = categoryManegerDTO.DateModefied; category.DateAdded = categoryManegerDTO.DateCreation; category.ParentId = categoryManegerDTO.ParentId; category = unitOfWork.CategoryRepository.Insert(category); CategoryDescription arabicCategoryDescription = new CategoryDescription(); arabicCategoryDescription.LanguageId = (long)Langs.Arabic; arabicCategoryDescription.Description = categoryManegerDTO.ArabicDescription; arabicCategoryDescription.Name = categoryManegerDTO.ArabicName; arabicCategoryDescription.MetaDescription = categoryManegerDTO.ArabicMetaDescription; arabicCategoryDescription.CategoryId = category.Id; arabicCategoryDescription.DateAdded = categoryManegerDTO.DateCreation; arabicCategoryDescription.DateModefied = categoryManegerDTO.DateModefied; CategoryDescription englishCategoryDescription = new CategoryDescription(); englishCategoryDescription.LanguageId = (long)Langs.English; englishCategoryDescription.Description = categoryManegerDTO.EnglishDescription; englishCategoryDescription.Name = categoryManegerDTO.EnglishName; englishCategoryDescription.MetaDescription = categoryManegerDTO.EnglishMetaDescription; englishCategoryDescription.CategoryId = category.Id; englishCategoryDescription.DateAdded = categoryManegerDTO.DateCreation; englishCategoryDescription.DateModefied = categoryManegerDTO.DateModefied; unitOfWork.CategoryDescriptionRepository.Insert(englishCategoryDescription); unitOfWork.CategoryDescriptionRepository.Insert(arabicCategoryDescription); unitOfWork.Save(); return(new OperationDetails(true, "تم الاضافة بنجاح", "")); }
public OperationDetails EditCategoryManager(CategoryManegerDTO categoryManegerDTO) { Category category = unitOfWork.CategoryRepository.GetByID(categoryManegerDTO.Id); if (category == null) { return(new OperationDetails(false, "حدث خطأ أثناء عملية التعديل", "")); } CategoryDescription arabicCategoryDescription = category.CategoryDescriptions.Where(c => c.LanguageId == Utils.getLanguage(Langs.Arabic)).FirstOrDefault(); arabicCategoryDescription.Name = categoryManegerDTO.ArabicName; arabicCategoryDescription.MetaDescription = categoryManegerDTO.ArabicMetaDescription; arabicCategoryDescription.Description = categoryManegerDTO.ArabicDescription; arabicCategoryDescription.DateModefied = DateTime.Now; CategoryDescription englishCategoryDescription = category.CategoryDescriptions.Where(c => c.LanguageId == Utils.getLanguage(Langs.English)).FirstOrDefault(); englishCategoryDescription.Name = categoryManegerDTO.EnglishName; englishCategoryDescription.MetaDescription = categoryManegerDTO.EnglishMetaDescription; englishCategoryDescription.Description = categoryManegerDTO.EnglishDescription; englishCategoryDescription.DateModefied = DateTime.Now; unitOfWork.CategoryDescriptionRepository.Update(englishCategoryDescription); unitOfWork.CategoryDescriptionRepository.Update(arabicCategoryDescription); category.ImageUrl = categoryManegerDTO.ImageUrl == "" ? DefaultImages.Category : categoryManegerDTO.ImageUrl; category.ImageThumb = categoryManegerDTO.ImageThumb == "" ? DefaultImages.Category : categoryManegerDTO.ImageThumb; category.Banner = categoryManegerDTO.BannerImage == "" ? DefaultImages.Banner : categoryManegerDTO.BannerImage; category.SortOrder = categoryManegerDTO.SortOrder; category.Status = categoryManegerDTO.Status; category.DateModified = DateTime.Now; category.ParentId = categoryManegerDTO.ParentId; unitOfWork.CategoryRepository.Update(category); unitOfWork.Save(); return(new OperationDetails(true, "تم التعديل بنجاح", "")); }
public LocalizedCategoryDescription(CategoryDescription description) { this.description = description; }
public void AddCategoryDescription(CategoryDescription categoryDescription) { _repository.Add <CategoryDescription>(categoryDescription); _repository.Commit(); }