Exemple #1
0
        public bool AddEditCoachMaster(CoachVMModel pr)
        {
            bool isUpdate = false;

            try
            {
                if (pr.ID == 0)
                {
                    Coach _coach = new Coach();
                    _coach.CoachName = pr.CoachName;
                    _db.Coaches.Add(_coach);
                    _db.SaveChanges();
                    isUpdate = true;
                }
                else
                {
                    var _coach = _db.Coaches.Where(x => x.ID == pr.ID).FirstOrDefault();
                    if (_coach != null)
                    {
                        _coach.CoachName = pr.CoachName;
                        _db.SaveChanges();
                        isUpdate = true;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(isUpdate);
        }
Exemple #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            CoachVMModel pr = new CoachVMModel();

            pr.CoachName = txtCoachName.Text.Trim();
            if (HiddenField1.Value != "")
            {
                pr.ID = Convert.ToInt32(HiddenField1.Value);
            }
            bool result = _service.AddEditCoachMaster(pr);

            if (result)
            {
                Response.Write("<script>alert('Record saved successfully')</script>");
            }
            bindGrid();
        }