public ActionResult Create(TradeAffiliationSouModel tradeAffiliationSouModel)
 {
     try
     {
         TradeAffiliationSou tradeAffiliationSou = new TradeAffiliationSou
         {
             ID          = tradeAffiliationSouModel.ID,
             TradeName   = tradeAffiliationSouModel.TradeName,
             FirstUnit   = tradeAffiliationSouModel.FirstUnit,
             SecondUnit  = tradeAffiliationSouModel.SecondUnit,
             ThirdUnit   = tradeAffiliationSouModel.ThirdUnit,
             SessionYear = tradeAffiliationSouModel.SessionYear,
         };
         if (ModelState.IsValid)
         {
             if (tradeAffiliationSou.ID > 0)
             {
                 tradeAffiliationSouRepository.UpdateTradeAffiliationSou(tradeAffiliationSou);
             }
             else
             {
                 tradeAffiliationSouRepository.InsertTradeAffiliationSou(tradeAffiliationSou);
             }
         }
         else
         {
             return(View(tradeAffiliationSouModel));
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         return(View(tradeAffiliationSouModel));
     }
 }
        public TradeAffiliationSou InsertTradeAffiliationSou(TradeAffiliationSou tradeAffiliationSou)
        {
            var inserted = iTIDataEntities.TradeAffiliationSous.Add(tradeAffiliationSou);

            iTIDataEntities.SaveChanges();
            return(inserted);
        }
        public ActionResult Delete(int id = 0)
        {
            TradeAffiliationSou tradeAffiliationSou = new TradeAffiliationSou();

            if (id > 0)
            {
                tradeAffiliationSouRepository.DelectTradeAffiliationSou(id);
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(int id = 0)
        {
            TradeAffiliationSou tradeAffiliationSou = new TradeAffiliationSou();

            if (id > 0)
            {
                tradeAffiliationSou = tradeAffiliationSouRepository.GetTradeAffiliationSouById(id);
            }
            ViewBag.Trade = StaticData.GetTrade();
            TradeAffiliationSouModel tradeAffiliationSouModel = new TradeAffiliationSouModel
            {
                ID          = tradeAffiliationSou.ID,
                TradeName   = tradeAffiliationSou.TradeName,
                FirstUnit   = tradeAffiliationSou.FirstUnit,
                SecondUnit  = tradeAffiliationSou.SecondUnit,
                ThirdUnit   = tradeAffiliationSou.ThirdUnit,
                SessionYear = tradeAffiliationSou.SessionYear,
            };

            return(View(tradeAffiliationSouModel));
        }
 public TradeAffiliationSou UpdateTradeAffiliationSou(TradeAffiliationSou tradeAffiliationSou)
 {
     iTIDataEntities.Entry(tradeAffiliationSou).State = EntityState.Modified;
     iTIDataEntities.SaveChanges();
     return(tradeAffiliationSou);
 }