예제 #1
0
        public string Put(JobRefModel refModel)
        {
            string success = "";

            try
            {
                using (var db = new GetaJobContext())
                {
                    JobRef @ref = db.JobRefs.Where(r => r.RefCode == refModel.RefCode).First();
                    @ref.RefDescription = refModel.RefDescription;
                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex) { success = ex.Message; }
            return(success);
        }
예제 #2
0
        public JobRefModel Post(JobRefModel refModel)
        {
            try
            {
                using (var db = new GetaJobContext())
                {
                    var @ref = new JobRef();
                    @ref.RefType        = refModel.RefType;
                    @ref.RefCode        = GetUniqueRefCode(refModel.RefDescription, db);
                    @ref.RefDescription = refModel.RefDescription;

                    db.JobRefs.Add(@ref);
                    db.SaveChanges();
                    refModel.RefCode = @ref.RefCode;
                    refModel.Success = "ok";
                }
            }
            catch (Exception ex)
            {
                refModel.Success = ex.Message;
            }
            return(refModel);
        }