public static void InitializeInternal_ThrowsConfigurationErrorsException_ForMissingDefaultProviderProperty() { // Arrange var section = new AssetSection(); // Act & Assert Assert.Throws <ConfigurationErrorsException>(() => AssetManager.InitializeCore(section)); }
public void Delete(AssetSection ObjDelete) { var ObjToDelete = _context.AssetSections.SingleOrDefault(m => m.CompanyID == ObjDelete.CompanyID && m.SectionID == ObjDelete.SectionID); if (ObjToDelete != null) { _context.AssetSections.Remove(ObjToDelete); } }
public static IValidator <SafeRateSection> GetValidator() { var v = new InlineValidator <SafeRateSection>() { CascadeMode = CascadeMode.Continue }; v.RuleFor(_ => _.Gold).NotNull().SetValidator(AssetSection.GetValidator()); v.RuleFor(_ => _.Eth).NotNull().SetValidator(AssetSection.GetValidator()); return(v); }
public ActionResult AddNew() { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); AssetSection Obj = new AssetSection { SectionID = _unitOfWork.AssetSection.GetMaxSerial(UserInfo.fCompanyId) }; return(PartialView(Obj)); }
public void Update(AssetSection ObjUpdate) { var ObjToUpdate = _context.AssetSections.FirstOrDefault(m => m.CompanyID == ObjUpdate.CompanyID && m.SectionID == ObjUpdate.SectionID); if (ObjToUpdate != null) { ObjToUpdate.SectionName = ObjUpdate.SectionName; ObjToUpdate.InsDateTime = ObjUpdate.InsDateTime; ObjToUpdate.InsUserID = ObjUpdate.InsUserID; } }
public JsonResult SaveAssetSection(AssetSection ObjSave) { MsgUnit Msg = new MsgUnit(); try { var userId = User.Identity.GetUserId(); var UserInfo = _unitOfWork.User.GetMyInfo(userId); ObjSave.SectionID = _unitOfWork.AssetSection.GetMaxSerial(UserInfo.fCompanyId); ObjSave.InsDateTime = DateTime.Now; ObjSave.InsUserID = userId; ObjSave.CompanyID = UserInfo.fCompanyId; if (!ModelState.IsValid) { string Err = " "; var errors = ModelState.Values.SelectMany(v => v.Errors); foreach (ModelError error in errors) { Err = Err + error.ErrorMessage + " * "; } Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + Err; Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } _unitOfWork.AssetSection.Add(ObjSave); _unitOfWork.Complete(); Msg.LastID = _unitOfWork.AssetSection.GetMaxSerial(UserInfo.fCompanyId).ToString(); Msg.Code = 1; Msg.Msg = Resources.Resource.AddedSuccessfully; return(Json(Msg, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Msg.Msg = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString(); Msg.Code = 0; return(Json(Msg, JsonRequestBehavior.AllowGet)); } }
// Internal-only method for testing. // We use temporary objects to achieve exception-neutral code. internal static void InitializeCore(AssetSection section) { Debug.Assert(section != null); // Initialize the provider collection. var tmpProviders = new AssetProviderCollection(); if (section.Providers != null) { ProvidersHelper.InstantiateProviders(section.Providers, tmpProviders, typeof(AssetProvider)); tmpProviders.SetReadOnly(); } s_Providers = tmpProviders; // Initialize the default provider. if (section.DefaultProvider == null) { throw new ProviderException(Strings.AssetManager_DefaultProviderNotConfigured); } var tmpProvider = s_Providers[section.DefaultProvider]; if (tmpProvider == null) { // section.DefaultProvider is not null => propertyInfo != null. var propertyInfo = section.ElementInformation .Properties[AssetSection.DefaultProviderPropertyName]; throw new ConfigurationErrorsException( Strings.AssetManager_DefaultProviderNotFound, propertyInfo.Source, propertyInfo.LineNumber); } s_Provider = tmpProvider; }
public void Add(AssetSection ObjSave) { _context.AssetSections.Add(ObjSave); }