Beispiel #1
0
 public IActionResult Index(int page = 1)
 {
     return(View(new CodesViewModel
     {
         Codes = codeRepository.FindPage(page),
         CodeCount = codeRepository.FindAll().Count(),
         ActivePage = page
     }));
 }
Beispiel #2
0
        public GeneralResponse ChangeCodeName()
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                IEnumerable <Code> codes = _codeRepository.FindAll();
                var res = codes.Select(x => new { ID = x.Center.ID, code = x.CodeName }).ToList();
                foreach (var re in res)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        string c       = string.Concat(re.code, i.ToString());
                        Code   newCode = new Code();
                        newCode.Center         = _centerRepository.FindBy(re.ID);
                        newCode.CreateDate     = PersianDateTime.Now;
                        newCode.CreateEmployee =
                            _employeeRepository.FindBy(Guid.Parse("12D942E9-9B2F-42A9-82D5-66D661FAC17D"));
                        newCode.ID               = Guid.NewGuid();
                        newCode.ModifiedDate     = null;
                        newCode.ModifiedEmployee = null;
                        newCode.RowVersion       = 1;
                        newCode.CodeName         = c;
                        _codeRepository.Add(newCode);
                    }
                }
                _uow.Commit();
                //IList<Code> TempCode = new List<Code>();
                //foreach (var code in codes)
                //{

                //    for (int i = 0; i < 10; i++)
                //    {
                //        if (code.CodeName == "4408")
                //        {
                //            int a = 1;
                //        }
                //        Code newCode = new Code();
                //        newCode.Center = _centerRepository.FindBy(code.Center.ID);
                //        newCode.CreateDate = code.CreateDate;
                //        newCode.CreateEmployee = code.CreateEmployee;
                //        newCode.ID = Guid.NewGuid();
                //        newCode.ModifiedDate = code.ModifiedDate;
                //        newCode.ModifiedEmployee = code.ModifiedEmployee;
                //        newCode.RowVersion = 1;
                //        newCode.CodeName = string.Concat(code.CodeName, i.ToString());
                //        TempCode.Add(newCode);

                //    }
                //}
                //foreach (var item in TempCode)
                //{
                //    _codeRepository.Add(item);
                //    _uow.Commit();
                //}
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }