Пример #1
0
        public static void InitializeInternal_ThrowsConfigurationErrorsException_ForMissingDefaultProviderProperty()
        {
            // Arrange
            var section = new AssetSection();

            // Act & Assert
            Assert.Throws <ConfigurationErrorsException>(() => AssetManager.InitializeCore(section));
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
                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);
                }
Пример #4
0
        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));
        }
Пример #5
0
        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;
            }
        }
Пример #6
0
        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));
            }
        }
Пример #7
0
        // 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;
        }
Пример #8
0
 public void Add(AssetSection ObjSave)
 {
     _context.AssetSections.Add(ObjSave);
 }