コード例 #1
0
        public ActionResult UpsertItem(Kpt.KptType type, Kpt info = null)
        {
            //(int id = 1, string typeid = null, Kpt info = null)
            var hasError = false;

            /*
             * if (!ViewData.ModelState.IsValid)
             * {
             *  hasError = true;
             * }
             *
             * if (hasError)
             * {
             *  var validatedModel = _basePriceLogic.GetModel(id, typeid, info);
             *  ViewBag.ErrorTypeId = typeid;
             *  ViewBag.ErrorPricingType = info.PricingType;
             *  return View("Index", validatedModel);
             * }
             */
            /*
             * if (info.ID == 0)
             * {
             *  _kptListLogic.AddPricing(typeid, info);
             * }
             * else
             * {
             *  _kptListLogic.UpdatePricing(typeid, info);
             * }
             */
            kptListLogic.AddItem(type, info);
            //var model = _kptListLogic.GetModel(type);
            return(View("Index"));
        }
コード例 #2
0
ファイル: KptListLogic.cs プロジェクト: furikaeru/furikaeru
 /// <summary>
 /// KPT変更
 /// </summary>
 /// <param name="typeid"></param>
 /// <param name="info"></param>
 public void DeleteItem(Kpt.KptType type, Kpt info)
 {
     /*
      * var delPricing = _optimDbContext.ThreadSafe(context => context.Pricing.Include(x => x.DeploymentType)
      *  .FirstOrDefaultAsync(x => x.DeploymentType.ID == typeid && x.ID == info.ID));
      * if (delPricing != null)
      * {
      *  // 基本単価の場合は自動で終了日を設定
      *  if (delPricing.PricingType == Common.DatabaseConnector.Models.PricingTypeEnum.Base)
      *  {
      *      var pricing = _optimDbContext.ThreadSafe(context => context.Pricing.Include(x => x.DeploymentType)
      *          .Where(x => x.DeploymentType.ID == typeid && x.PricingType == delPricing.PricingType)
      *          .OrderByDescending(x => x.EndDate)
      *          .FirstOrDefaultAsync(x => x.EndDate.HasValue));
      *      if (pricing != null)
      *      {
      *          pricing.EndDate = null;
      *          _optimDbContext.Update(pricing);
      *      }
      *  }
      *  _optimDbContext.Remove(delPricing);
      *  _optimDbContext.ThreadSafe(context => context.SaveChangesAsync());
      * }
      */
 }
コード例 #3
0
ファイル: TableUtils.cs プロジェクト: furikaeru/furikaeru
        /// <summary>
        /// Kptを削除する
        /// </summary>
        /// <param name="boardId">ボードID</param>
        /// <param name="type">Kpt種別</param>
        /// <param name="kptItem">削除アイテム</param>
        public async Task DelKptAsync(int boardId, KptType type, Kpt kptItem)
        {
            CloudTable table = this.Client.GetTableReference(TblKpt);

            var emp = new KptEntity(boardId, type, kptItem.UserName, kptItem.Title, kptItem.Comment)
            {
                ETag = "*"
            };
            TableOperation deleteOp = TableOperation.Delete(emp);
            await table.ExecuteAsync(deleteOp);
        }
コード例 #4
0
ファイル: KptListLogic.cs プロジェクト: furikaeru/furikaeru
 /// <summary>
 /// KPT追加
 /// </summary>
 /// <param name="typeid"></param>
 /// <param name="info"></param>
 public void AddItem(Kpt.KptType type, Kpt info)
 {
     /*
      * var deploymentType = _optimDbContext.ThreadSafe(context => context.DeploymentTypes.FirstAsync(x => x.ID == typeid));
      *
      * var addInfo = Mapper.Map<Common.DatabaseConnector.Models.Pricing>(info);
      * addInfo.DeploymentType = deploymentType;
      * _optimDbContext.DeploymentTypes.Attach(deploymentType);
      *
      * _optimDbContext.Add(addInfo);
      * _optimDbContext.ThreadSafe(context => context.SaveChangesAsync());
      */
 }
コード例 #5
0
ファイル: KptListLogic.cs プロジェクト: furikaeru/furikaeru
 /// <summary>
 /// KPT変更
 /// </summary>
 /// <param name="typeid"></param>
 /// <param name="info"></param>
 public void UpdateItem(Kpt.KptType type, Kpt info)
 {
     /*
      * var updPricing = _optimDbContext.ThreadSafe(context => context.Pricing.Include(x => x.DeploymentType)
      *  .FirstOrDefaultAsync(x => x.DeploymentType.ID == typeid && x.ID == info.ID));
      * if (updPricing != null)
      * {
      *  var updateInfo = Mapper.Map<Common.DatabaseConnector.Models.Pricing>(info);
      *  updPricing.StartDate = updateInfo.StartDate;
      *  updPricing.EndDate = updateInfo.EndDate;
      *  updPricing.MonthlyPrice = updateInfo.MonthlyPrice;
      *  _optimDbContext.Update(updPricing);
      *  _optimDbContext.ThreadSafe(context => context.SaveChangesAsync());
      * }
      */
 }
コード例 #6
0
ファイル: TableUtils.cs プロジェクト: furikaeru/furikaeru
        /// <summary>
        /// Kptリストを取得する
        /// </summary>
        /// <param name="boardId">ボードID</param>
        /// <param name="type">Kptの種別</param>
        /// <returns>Kptリスト</returns>
        public List <Kpt> GetKptList(int boardId, KptType type)
        {
            CloudTable             table             = this.Client.GetTableReference(TblKpt);
            TableQuery <KptEntity> query             = new TableQuery <KptEntity>().Where(TableQuery.GenerateFilterCondition(PartitonKey, QueryComparisons.Equal, this.GetKptTableKey(boardId, type)));
            TableContinuationToken continuationToken = null;
            var items  = new List <KptEntity>(table.ExecuteQuerySegmentedAsync <KptEntity>(query, continuationToken).Result);
            var result = new List <Kpt>();

            foreach (var item in items)
            {
                var kpt = new Kpt()
                {
                    Type     = type,
                    UserName = item.UserName,
                    Title    = item.Title,
                    Comment  = item.Comment
                };
                result.Add(kpt);
            }
            return(result);
        }
コード例 #7
0
 public ActionResult DeleteItem(Kpt.KptType type, Kpt info = null)
 {
     /*
      *  var hasError = false;
      *
      *  if (!_basePriceLogic.CheckValidPeriod(typeid, info, false))
      *  {
      *      hasError = true;
      *      ViewData.ModelState.AddModelError(nameof(info.StartDate), string.Format(Constants.Messages.ERROR_CHECK_VALID_PERIOD, "削除"));
      *  }
      *
      *  if (hasError)
      *  {
      *      var validatedModel = _basePriceLogic.GetModel(id, typeid, info);
      *      ViewBag.ErrorTypeId = typeid;
      *      ViewBag.ErrorPricingType = info.PricingType;
      *      return View("Index", validatedModel);
      *  }
      */
     kptListLogic.DeleteItem(type, info);
     //var model = _kptListLogic.GetModel(type);
     return(View("Index"));
 }
コード例 #8
0
        public async System.Threading.Tasks.Task <ActionResult> KptInput(KptListModel inputModel, IList <Kpt> kpt, string inputitem, string commititem)
        {
            var list = kpt;

            if (list == null || list.Count == 0)
            {
                list = new List <Kpt>();
            }

            //セッションから取得する。
            var username = HttpContext.Request.Cookies[cUserName];

            if (inputitem != null)
            {
                Kpt newkpt = new Kpt()
                {
                    Type     = inputModel.InputType,
                    UserName = username,
                    Title    = inputModel.Title,
                    Comment  = inputModel.Comment
                };
                list.Add(newkpt);

                //リスト置き換え
                ModelState.Clear();
                inputModel.Title           = string.Empty;
                inputModel.Comment         = string.Empty;
                inputModel.KptList         = list;
                inputModel.IsDeleteMode    = false;
                inputModel.DeleteItemIndex = -1;

                return(View(inputModel));
            }

            //リストから項目を削除する。
            if (inputModel.IsDeleteMode)
            {
                Kpt delItem = list[inputModel.DeleteItemIndex];

                //テーブルに既に登録されている場合は、削除する。
                IList <Kpt> tlist   = kptListLogic.GetUserKptList(inputModel.BoardId, inputModel.InputType, username);
                var         isExist = tlist.Any(x => x.Title == delItem.Title);

                if (isExist)
                {
                    //KPTアイテムの削除
                    await tableUtils.DelKptAsync(inputModel.BoardId, inputModel.InputType, delItem);
                }

                //リストから削除
                list.RemoveAt(inputModel.DeleteItemIndex);

                //リスト置き換え
                ModelState.Clear();
                inputModel.Title           = string.Empty;
                inputModel.Comment         = string.Empty;
                inputModel.KptList         = list;
                inputModel.IsDeleteMode    = false;
                inputModel.DeleteItemIndex = -1;

                return(View(inputModel));
            }


            //リストの登録
            await tableUtils.CommitKptListByUserAsync(inputModel.BoardId, username, inputModel.InputType, list.ToList());

            if (inputModel.InputType == KptType.Try)
            {
                return(Redirect("/Kpt/Index?boardId=" + inputModel.BoardId + "&type=" + inputModel.InputType));
            }
            return(Redirect("/Kpt/KptInput?boardId=" + inputModel.BoardId + "&type=" + (inputModel.InputType + 1)));
        }