コード例 #1
0
        public string DeleteStore(int StoreId, string DeleteBy)
        {
            string jsonResult           = string.Empty;
            RepoReturnViewModel oReturn = new RepoReturnViewModel();

            try
            {
                var oExistData = _db.Stores.Where(x => x.StoreId == StoreId).FirstOrDefault();
                if (oExistData != null)
                {
                    oExistData.EditBy   = DeleteBy;
                    oExistData.EditDate = DateTime.Now;
                    oExistData.IsDelete = 1;
                    _db.Update(oExistData);
                    oReturn.Payload  = oExistData;
                    oReturn.Messages = "Data Deleted In The Database";
                }
                else
                {
                    oReturn.Payload  = null;
                    oReturn.Messages = "Data Failed To Delete In The Database";
                }
                jsonResult = JsonConvert.SerializeObject(oReturn);
            }
            catch (Exception ex)
            {
                returnMessage    = ex.Message;
                oReturn.Payload  = null;
                oReturn.Messages = ex.Message;
                jsonResult       = JsonConvert.SerializeObject(oReturn);
            }

            return(jsonResult);
        }
コード例 #2
0
        public string UpdateStore(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.Update(param);
                    oReturn.Payload  = param;
                    oReturn.Messages = "Data Updated In The Database";
                }
                else
                {
                    oReturn.Payload  = null;
                    oReturn.Messages = "Store " + param.Nama + " Already Exist In Database";
                }
                jsonResult = JsonConvert.SerializeObject(oReturn);
            }
            catch (Exception ex)
            {
                returnMessage    = ex.Message;
                oReturn.Payload  = null;
                oReturn.Messages = ex.Message;
                jsonResult       = JsonConvert.SerializeObject(oReturn);
            }

            return(jsonResult);
        }
コード例 #3
0
        public string SaveUser(User param)
        {
            RepoReturnViewModel oReturn = new RepoReturnViewModel();
            string jsonResult           = string.Empty;

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

            return(jsonResult);
        }
コード例 #4
0
        public string UpdateDistributor(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.Update(param);
                    oReturn.Payload  = param;
                    oReturn.Messages = "Data Successfully Updated In The Database";
                }
                else
                {
                    oReturn.Payload  = null;
                    oReturn.Messages = "Data Already Exist In The Database";
                }
                jsonResult = JsonConvert.SerializeObject(oReturn);
            }
            catch (Exception ex)
            {
                returnMessage    = ex.Message;
                oReturn.Payload  = null;
                oReturn.Messages = ex.Message;
                jsonResult       = JsonConvert.SerializeObject(oReturn);
            }

            return(jsonResult);
        }
コード例 #5
0
        public string SaveProdusen(MsAktor param)
        {
            string jsonResult           = string.Empty;
            RepoReturnViewModel oReturn = new RepoReturnViewModel();

            try
            {
                var oExistData = _db.MsAktor.Where(x => x.Nama == param.Nama && x.RoleId == 3).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);
        }
コード例 #6
0
        public JsonResult DeleteUser(string userId)
        {
            RepoReturnViewModel <User> o = new RepoReturnViewModel <User>();
            string returnMessage         = string.Empty;
            string strRepo = string.Empty;

            try
            {
                strRepo = _repository.DeleteUser(Convert.ToInt32(userId), _session.NamaAktor);
                o       = JsonConvert.DeserializeObject <RepoReturnViewModel <User> >(strRepo);
            }
            catch (Exception ex)
            {
                o.Payload  = null;
                o.Messages = ex.Message;
            }
            return(Json(new { data = o.Payload, message = o.Messages }));
        }
コード例 #7
0
        public JsonResult UpdatePetani(MsAktor param)
        {
            RepoReturnViewModel <MsAktor> o = new RepoReturnViewModel <MsAktor>();
            string returnMessage            = string.Empty;
            string strRepo = string.Empty;

            try
            {
                param.EditDate = DateTime.Now;
                param.EditBy   = _session.NamaAktor;
                strRepo        = _repository.UpdatePetani(param);
                o = JsonConvert.DeserializeObject <RepoReturnViewModel <MsAktor> >(strRepo);
            }
            catch (Exception ex)
            {
                o.Payload  = null;
                o.Messages = ex.Message;
            }
            return(Json(new { data = o.Payload, message = o.Messages }));
        }
コード例 #8
0
        public JsonResult CreatePupuk(MsPupuk param)
        {
            RepoReturnViewModel <MsPupuk> o = new RepoReturnViewModel <MsPupuk>();
            string returnMessage            = string.Empty;
            string strRepo = string.Empty;

            try
            {
                param.AddDate = DateTime.Now;
                param.AddBy   = _session.NamaAktor;
                strRepo       = _repository.SavePupuk(param);
                o             = JsonConvert.DeserializeObject <RepoReturnViewModel <MsPupuk> >(strRepo);
            }
            catch (Exception ex)
            {
                o             = null;
                returnMessage = ex.Message;
            }

            return(Json(new { data = o.Payload, message = o.Messages }));
        }
コード例 #9
0
        public JsonResult CreateDistributor(MsAktor param)
        {
            RepoReturnViewModel <MsAktor> o = new RepoReturnViewModel <MsAktor>();
            string returnMessage            = string.Empty;
            string strRepo = string.Empty;

            try
            {
                param.Kode    = _repoHelper.GetDistributorCode();
                param.RoleId  = 2;
                param.AddDate = DateTime.Now;
                param.AddBy   = _session.NamaAktor;
                strRepo       = _repository.SaveDistributor(param);
                o             = JsonConvert.DeserializeObject <RepoReturnViewModel <MsAktor> >(strRepo);
            }
            catch (Exception ex)
            {
                o             = null;
                returnMessage = ex.Message;
            }

            return(Json(new { data = o.Payload, message = o.Messages }));
        }