Ejemplo n.º 1
0
        private void CommitToItem()
        {
            var userId = SessionData.Current.UserId;

            if (userId == 0)
            {
                Response.Redirect("/Logon");
            }

            var item = new HPPortal.Data.Models.OverviewPlan();

            if (PlanId > 0)
            {
                item = _db.OverviewPlans.Find(PlanId);
            }

            item.Strength    = txtStrength.Text.Trim();
            item.Weakness    = txtWeakness.Text.Trim();
            item.Opportunity = txtOpportunity.Text.Trim();
            item.SupportReqd = txtSupportReqd.Text.Trim();

            if (PlanId > 0)
            {
                item.ModifiedDate = System.DateTime.Now;
                item.ModifiedUser = userId;
            }
            else
            {
                item.PartnerId   = PartnerId;
                item.Quarter     = Quater;
                item.CreatedDate = System.DateTime.Now;
                item.CreatedUser = userId;
            }

            if (ModelState.IsValid)
            {
                if (PlanId > 0)
                {
                    _db.Entry <HPPortal.Data.Models.OverviewPlan>(item).State = EntityState.Modified;
                }
                else
                {
                    _db.OverviewPlans.Add(item);
                }

                _db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        // This is the Insert method to insert the entered OverviewPlan item
        // USAGE: <asp:FormView InsertMethod="InsertItem">
        public void InsertItem()
        {
            using (_db)
            {
                var item = new HPPortal.Data.Models.OverviewPlan();

                TryUpdateModel(item);

                if (ModelState.IsValid)
                {
                    // Save changes
                    _db.OverviewPlans.Add(item);
                    _db.SaveChanges();

                    Response.Redirect("Default");
                }
            }
        }