Beispiel #1
0
        public JsonResult SaveData(string strMagasin)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Magasin_DTO          magasin    = serializer.Deserialize <Magasin_DTO>(strMagasin);
            bool   status  = false;
            string message = string.Empty;

            //add new employee if id = 0
            if ((magasin.Code_magasin == null) || (magasin.libelle == null))
            {
                status = false;
            }

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

                    var entity = _MagasinAppService.GetById(magasin.Id);
                    entity.Code_magasin = magasin.Code_magasin;
                    entity.libelle      = magasin.libelle;
                    entity.tel          = magasin.tel;
                    entity.Adresse      = magasin.Adresse;
                    entity.obsrvation   = magasin.obsrvation;
                    entity.Id           = magasin.Id;

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

            return(Json(new
            {
                status = status,
                message = message
            }));
        }
Beispiel #2
0
 public ActionResult Add(Magasin_DTO obj)
 {
     if ((obj.Code_magasin == null) || (obj.libelle == null))
     {
         return(Json(false));
     }
     else
     {
         _MagasinAppService.Add(obj);
         return(Json(true));
     }
 }