Esempio n. 1
0
        public string SaveStore(Store param)
        {
            RepoReturnViewModel oReturn = new RepoReturnViewModel();
            string jsonResult           = string.Empty;

            try
            {
                var oExistData = _db.Stores.Where(x => x.Nama == param.Nama).FirstOrDefault();
                if (oExistData == null)
                {
                    _db.InsertWithIdentity(param);
                    oReturn.Payload  = param;
                    oReturn.Messages = "Data Successfully Save Into Database";
                }
                else
                {
                    oReturn.Payload  = null;
                    oReturn.Messages = "Store " + param.Nama + " Already Exist In Database";
                }
                jsonResult = JsonConvert.SerializeObject(oReturn);
            }
            catch (Exception ex)
            {
                oReturn.Payload  = null;
                oReturn.Messages = ex.Message;
                jsonResult       = JsonConvert.SerializeObject(oReturn);
            }

            return(jsonResult);
        }
Esempio n. 2
0
        public string SaveDistributor(MsAktor param)
        {
            string jsonResult           = string.Empty;
            RepoReturnViewModel oReturn = new RepoReturnViewModel();

            try
            {
                var oExistData = _db.MsAktor.Where(x => x.Nama == param.Nama && x.RoleId == 2).FirstOrDefault();
                if (oExistData == null)
                {
                    _db.InsertWithIdentity(param);
                    oReturn.Payload  = param;
                    oReturn.Messages = "Data Successfully Saved Into Database";
                }
                else
                {
                    oReturn.Payload  = null;
                    oReturn.Messages = "Data Already Exist In The Database";
                }
                jsonResult = JsonConvert.SerializeObject(oReturn);
            }
            catch (Exception ex)
            {
                oReturn.Payload  = null;
                oReturn.Messages = ex.Message;
                jsonResult       = JsonConvert.SerializeObject(oReturn);
            }

            return(jsonResult);
        }