示例#1
0
        public JsonResult delete(int id)
        {
            try
            {
                delegator dele = DB.delegator.Where(x => x.id == id).Single();

                DB.delegator.Remove(dele);
                DB.SaveChanges();

                return(Json(new { msg = "تمت حذف المندوب بنجاح" }));
            }
            catch
            {
                return(Json(new { msg = "لم تتم عمليه الحذف .. حاول مره اخري" }));
            }
        }
示例#2
0
        public JsonResult add_delegator(string name, string phone, string address, int agentId)
        {
            try
            {
                delegator g = new delegator();
                g.name    = name;
                g.phone   = phone;
                g.address = address;
                g.agent   = DB.agent.Where(a => a.id == agentId).Single();
                g.active  = 1;
                DB.delegator.Add(g);
                DB.SaveChanges();

                return(Json(new { msg = "تمت اضافه المندوب بنجاح" }));
            }
            catch
            {
                return(Json(new { msg = "لم تتم عمليه الاضافه .. حاول مره اخري" }));
            }
        }
示例#3
0
        public JsonResult update_delegator(int id, string name, string phone, string address, int agentId, int active)
        {
            try
            {
                delegator g = DB.delegator.Where(x => x.id == id).Single();
                g.name    = name;
                g.phone   = phone;
                g.address = address;
                g.agent   = DB.agent.Where(a => a.id == agentId).Single();
                g.active  = active;

                DB.Entry(g).State = EntityState.Modified;
                DB.SaveChanges();

                return(Json(new { msg = "تمت تعديل  بيانات المندوب بنجاح" }));
            }
            catch
            {
                return(Json(new { msg = "لم تتم عمليه التعديل .. حاول مره اخري" }));
            }
        }