public ActionResult Add(Consigne_maintenance_DTO obj)
 {
     if (!ModelState.IsValid)
     {
         return(Json(false));
     }
     else
     {
         _Consigne_maintenanceAppService.Add(obj);
         return(Json(true));
     }
 }
        public JsonResult SaveData(string strConsigne)
        {
            JavaScriptSerializer     serializer = new JavaScriptSerializer();
            Consigne_maintenance_DTO consigne   = serializer.Deserialize <Consigne_maintenance_DTO>(strConsigne);
            bool   status  = false;
            string message = string.Empty;

            //add new employee if id = 0
            if ((consigne.Code_Consigne == null) || (consigne.Designation == null))
            {
                status = false;
            }

            else
            {
                if (consigne.Id == 0)
                {
                    try
                    {
                        _Consigne_maintenanceAppService.Add(consigne);
                        status = true;
                    }
                    catch (Exception ex)
                    {
                        status  = false;
                        message = ex.Message;
                    }
                }
                else
                {
                    //update existing DB
                    //save db

                    var entity = _Consigne_maintenanceAppService.GetById(consigne.Id);
                    entity.Code_Consigne     = consigne.Code_Consigne;
                    entity.Designation       = consigne.Designation;
                    entity.Description       = consigne.Description;
                    entity.Duré_cons_jr      = consigne.Duré_cons_jr;
                    entity.Duré_cons_h       = consigne.Duré_cons_h;
                    entity.Nb_interv_suggéré = consigne.Nb_interv_suggéré;

                    entity.Id = consigne.Id;

                    try
                    {
                        _Consigne_maintenanceAppService.Update(entity);
                        status = true;
                    }
                    catch (Exception ex)
                    {
                        status  = false;
                        message = ex.Message;
                    }
                }
            }

            return(Json(new
            {
                status = status,
                message = message
            }));
        }