Exemple #1
0
        public async Task <JsonResult> Edit([FromBody] Event2 event2)
        {
            AppIdentityUser _user = await _userManager.FindByNameAsync(User.Identity.Name);

            BrhScalp brhScalp = new BrhScalp();

            var ParentType = typeof(BrhScalp);
            var Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(brhScalp, Propertie.GetValue(event2, null), null);
                }
            }
            _context.Update(brhScalp);
            _context.SaveChanges();

            var total             = _context.BrhScalp.Where(x => x.ImprestAccountsId == brhScalp.ImprestAccountsId && !x.IsMove).Sum(x => x.TotalPrice);
            var brhImprestAccount = _context.BrhImprestAccounts.SingleOrDefault(x => x.ImprestAccountsId == brhScalp.ImprestAccountsId);

            brhImprestAccount.Equity = brhImprestAccount.Balance - total;
            _context.Update(brhImprestAccount);
            await _context.SaveChangesAsync();

            return(Json(event2));
        }
Exemple #2
0
        public async Task <JsonResult> Create([FromBody] Event2 event2)
        {
            AppIdentityUser _user = await _userManager.FindByNameAsync(User.Identity.Name);

            var ScalpId = Convert.ToInt64(_user.BranchId.ToString() + ConvertJson.DateTimeToStamp(DateTime.Now).ToString());

            event2.EnteringDate = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"));
            event2.ScalpId      = ScalpId;
            event2.id           = ScalpId.ToString();
            event2.resourceId   = event2.HouseNumber;
            event2.start        = event2.StartDate.ToShortDateString();
            event2.end          = event2.EndDate.ToShortDateString();
            var brhScalp   = new BrhScalp();
            var ParentType = typeof(BrhScalp);
            var Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(brhScalp, Propertie.GetValue(event2, null), null);
                }
            }
            _context.Add(brhScalp);
            await _context.SaveChangesAsync();

            var total             = _context.BrhScalp.Where(x => x.ImprestAccountsId == brhScalp.ImprestAccountsId && !x.IsMove).Sum(x => x.TotalPrice);
            var brhImprestAccount = _context.BrhImprestAccounts.SingleOrDefault(x => x.ImprestAccountsId == brhScalp.ImprestAccountsId);

            brhImprestAccount.Equity = brhImprestAccount.Balance - total;
            _context.Update(brhImprestAccount);
            await _context.SaveChangesAsync();

            return(Json(event2));
        }