示例#1
0
        public IActionResult DeleteFilm(Film film)
        {
            //string webRootPath = _hostingEnvironment.WebRootPath;

            //string jsonFile = Path.Combine(webRootPath, "files/dizifilm.json");

            //string jsonString = System.IO.File.ReadAllText(jsonFile);

            //using (StreamWriter sw = new StreamWriter(jsonFile))
            //{
            //    List<Film> jsonData3 = JsonConvert.DeserializeObject<List<Film>>(jsonString);

            //    Film silinecekFilm = jsonData3.SingleOrDefault(x => x.id == film.id);

            //    jsonData3.Remove(silinecekFilm);

            //    string yeniJson2 = JsonConvert.SerializeObject(jsonData3);

            //    sw.Write(yeniJson2);

            //    sw.Close();

            //    sw.Dispose();
            //}

            JsonHelper jsonHelper = new JsonHelper(_hostingEnvironment);

            jsonHelper.Delete(film);

            LogBeinHelper logHelper = new LogBeinHelper(_hostingEnvironment);

            logHelper.Insert("delete", Layer.Admin);

            return(RedirectToAction("Index", "HomeAdmin"));
        }
示例#2
0
        public IActionResult UpdateFilm(Film film)
        {
            JsonHelper jsonHelper = new JsonHelper(_hostingEnvironment);

            jsonHelper.Update(film);

            LogBeinHelper logHelper = new LogBeinHelper(_hostingEnvironment);

            logHelper.Insert("update", Layer.Admin);

            return(RedirectToAction("Index", "HomeAdmin"));
        }
示例#3
0
        public void FluentValidate(IValidator validator, object entity)
        {
            var result = validator.Validate(entity);

            if (result.Errors.Count > 0)
            {
                foreach (var error in result.Errors)
                {
                    LogBeinHelper logHelper = new LogBeinHelper(_hostingEnvironment);

                    logHelper.Insert("validate : " + error.ErrorMessage, Layer.Admin);
                }
            }
        }
示例#4
0
        private void WriteLogDetail(IInvocation invocation)
        {
            var logParameters = new List <string>();

            for (int i = 0; i < invocation.Arguments.Length; i++)
            {
                logParameters.Add(
                    "Name : " + invocation.GetConcreteMethod().GetParameters()[i].Name +
                    "Value : " + invocation.Arguments[i] +
                    "Type : " + invocation.Arguments[i].GetType().Name
                    );
            }

            LogBeinHelper helper = new LogBeinHelper(null);

            helper.Insert(String.Join(", ", logParameters.ToArray()), Layer.Admin);
        }
        public override void OnEntry(MethodExecutionArgs args)
        {
            var validator = (IValidator)Activator.CreateInstance(_validatorType);

            var entityType = _validatorType.BaseType.GetGenericArguments()[0];

            var entities = args.Arguments.Where(t => t.GetType() == entityType);

            foreach (var entity in entities)
            {
                ValidatorTool tool = new ValidatorTool(_hostingEnvironment);

                tool.FluentValidate(validator, entity);
            }

            LogBeinHelper logHelper = new LogBeinHelper(_hostingEnvironment);

            logHelper.Insert("onentry", Layer.Admin);
        }
        public override void OnExit(MethodExecutionArgs args)
        {
            LogBeinHelper logHelper = new LogBeinHelper(_hostingEnvironment);

            logHelper.Insert("onentry", Layer.Admin);
        }
        public override void OnException(MethodExecutionArgs args)
        {
            LogBeinHelper logHelper = new LogBeinHelper(_hostingEnvironment);

            logHelper.Insert(args.Exception.Message, Layer.Admin);
        }