コード例 #1
0
        public HttpResponseMessage updateFundcenter_POManager_Mapping(JObject json)
        {
            try
            {
                int center = 0; int manager = 0; int LastModifiedBy = 0; int fundmanagmap = 0;
                center       = json["FundCenterId"].ToObject <int>();
                manager      = json["POManagerId"].ToObject <int>();
                fundmanagmap = json["FundCenterPOMgrMappingId"].ToObject <int>();
                TEPOFundCenterPOMgrMapping Fund_Managermapping = new TEPOFundCenterPOMgrMapping();

                Fund_Managermapping.FundCenterId = center;
                Fund_Managermapping.CreatedBy    = GetLogInUserId();
                //Fund_Managermapping.POManagerId = LastModifiedBy;
                Fund_Managermapping.POManagerId = manager;
                Fund_Managermapping.FundCenterPOMgrMappingId = fundmanagmap;
                string mesg = "";
                if (Fund_Managermapping == null)
                {
                    mesg = "check object";
                    return(new HttpResponseMessage()
                    {
                        StatusCode = HttpStatusCode.NoContent,
                        Content = new StringContent(mesg)
                    });
                }
                //Fund_Managermapping.LastModifiedOn = DateTime.Now;
                var map = db.TEPOFundCenterPOMgrMappings.Single(a => a.FundCenterPOMgrMappingId == Fund_Managermapping.FundCenterPOMgrMappingId);
                if (map != null)
                {
                    map.FundCenterId   = Fund_Managermapping.FundCenterId;
                    map.POManagerId    = Fund_Managermapping.POManagerId;
                    map.LastModifiedOn = DateTime.Now;
                    db.Entry(map).CurrentValues.SetValues(map);
                    db.SaveChanges();
                }

                //db.Entry(map).CurrentValues.SetValues(Fund_Managermapping);
                //db.Entry(Fund_Managermapping).CurrentValues.SetValues(Fund_Managermapping);
                //db.SaveChanges();
                sinfo.errorcode    = 0;
                sinfo.errormessage = "Successfully Updated";
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new { info = sinfo })
                });
            }
            catch (Exception e)
            {
                ExceptionObj.RecordUnHandledException(e);
                return(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest,
                    Content = new StringContent(e.Message)
                });
            }
        }
コード例 #2
0
        // public HttpResponseMessage Fundcenter_POManager_Mapping(TEPOFundCenterPOMgrMapping Fund_Managermapping)
        public HttpResponseMessage Fundcenter_POManager_Mapping(JObject json)
        {
            try
            {
                int center = 0; int manager = 0; int LastModifiedBy = 0;

                // if (json["FundCenterId"] != null && json["FundCenterId"].ToString() != "")
                center  = json["FundCenterId"].ToObject <int>();
                manager = json["POManagerId"].ToObject <int>();

                TEPOFundCenterPOMgrMapping Fund_Managermapping = new TEPOFundCenterPOMgrMapping();

                Fund_Managermapping.FundCenterId = center;
                Fund_Managermapping.CreatedBy    = GetLogInUserId();
                //Fund_Managermapping.POManagerId = LastModifiedBy;
                Fund_Managermapping.POManagerId = json["POManagerId"].ToObject <int>();
                //TEPOFundCenterPOMgrMapping Fund_Managermapping = new TEPOFundCenterPOMgrMapping();
                //int center = json["FundCenterId"].ToObject<int>();
                string mesg = "";
                if (Fund_Managermapping == null)
                {
                    mesg = "check object";
                    return(new HttpResponseMessage()
                    {
                        StatusCode = HttpStatusCode.NoContent,
                        Content = new StringContent(mesg)
                    });
                }
                //Fund_Managermapping.FundCenterId = 1;
                //Fund_Managermapping.POManagerId = 1;
                //Fund_Managermapping.LastModifiedOn = DateTime.Now;
                Fund_Managermapping.CreatedOn = DateTime.Now;
                Fund_Managermapping.IsDeleted = false;
                db.TEPOFundCenterPOMgrMappings.Add(Fund_Managermapping);
                db.SaveChanges();
                sinfo.errorcode    = 0;
                sinfo.errormessage = "Successfully Saved";
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new { info = sinfo })
                });
            }
            catch (Exception e)
            {
                ExceptionObj.RecordUnHandledException(e);
                return(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest,
                    Content = new StringContent(e.Message)
                });
            }
        }
コード例 #3
0
        public HttpResponseMessage DeleteFundcenter_POManager_Mapping(JObject json)
        {
            try
            {
                int FundCenterPOMgrMappingId         = json["FundCenterPOMgrMappingId"].ToObject <int>();
                TEPOFundCenterPOMgrMapping FundPOMap = db.TEPOFundCenterPOMgrMappings.Where(a => a.FundCenterPOMgrMappingId == FundCenterPOMgrMappingId && a.IsDeleted == false).FirstOrDefault();
                if (FundPOMap != null)
                {
                    FundPOMap.LastModifiedOn = DateTime.Now;
                    FundPOMap.IsDeleted      = true;
                    db.Entry(FundPOMap).CurrentValues.SetValues(FundPOMap);
                    db.SaveChanges();

                    sinfo.errorcode    = 0;
                    sinfo.errormessage = "Successfully Deleted";
                    return(new HttpResponseMessage()
                    {
                        Content = new JsonContent(new { info = sinfo })
                    });
                }
                else
                {
                    sinfo.errorcode    = 0;
                    sinfo.errormessage = "Unable to Delete";
                    return(new HttpResponseMessage()
                    {
                        Content = new JsonContent(new { info = sinfo })
                    });
                }
            }
            catch (Exception ex)
            {
                ExceptionObj.RecordUnHandledException(ex);
                sinfo.errorcode    = 1;
                sinfo.errormessage = "Fail To Delete";
                return(new HttpResponseMessage()
                {
                    Content = new JsonContent(new { info = sinfo })
                });
            }
        }