Ejemplo n.º 1
0
        /// <summary>
        /// 조건에 맞는 데이터가 있으면 업데이트 그렇지 않으면 입력
        /// </summary>
        public void SaveOrUpdateProfit(int parentId, int monthNumber, int profit)
        {
            var twelve = _context.Twelves.Where(t => t.ParentId == parentId && t.MonthNumber == monthNumber).SingleOrDefault();

            if (twelve != null)
            {
                // Update
                twelve.Profit = profit;
                _context.Entry(twelve).State = Microsoft.EntityFrameworkCore.EntityState.Modified; // 수정 상태로 변경
                _context.SaveChanges();
            }
            else
            {
                // Insert
                var t = new Twelve()
                {
                    ParentId = parentId, MonthNumber = monthNumber, Profit = profit
                };
                _context.Twelves.Add(t);
                _context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 public bool Edit(Twelve model)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 3
0
 public Twelve Add(Twelve model)
 {
     throw new System.NotImplementedException();
 }