コード例 #1
0
        public HttpResponseMessage R2_AddLanguage()
        {
            var httpRequest = HttpContext.Current.Request;
            var lang        = JsonConvert.DeserializeObject <A0008>(httpRequest["lang"]);

            if (httpRequest.Files.Count > 0)
            {
                for (int i = 0; i < httpRequest.Files.Count; i++)
                {
                    HttpPostedFile file   = httpRequest.Files[i];
                    string         genkey = helper.GenKey();
                    string         ext    = helper.GetFileExtension(genkey + file.FileName);
                    file.SaveAs(HttpContext.Current.Server.MapPath("~/Portals/images/Users/" + genkey + file.FileName));
                    lang.Icon = "/Portals/images/Users/" + genkey + file.FileName;
                }
            }
            else
            {
                lang.Icon = null;
            }
            using (MeikoEntities db = new MeikoEntities())
            {
                var response = new HttpResponseMessage(HttpStatusCode.OK);
                var obj      = new A0008();
                obj.A0008_ID   = helper.GenKey();
                obj.tenNgonNgu = lang.tenNgonNgu;
                obj.Icon       = lang.Icon == null ? "Content/noimages.gif" : lang.Icon;
                obj.maCode     = lang.maCode;
                obj.thuTu      = lang.thuTu;
                obj.tinhTrang  = lang.tinhTrang;
                db.A0008.Add(obj);

                var checkLang = db.A0008.FirstOrDefault();
                if (checkLang != null)
                {
                    string NgonNguID = checkLang.A0008_ID;
                    var    LabelList = db.A0009.Where(x => x.A0008_ID == NgonNguID).ToList();
                    if (LabelList.Count > 0)
                    {
                        foreach (var item in LabelList)
                        {
                            var objlabel = new A0009();
                            objlabel.A0009_ID  = helper.GenKey();
                            objlabel.tenTieuDe = item.tenTieuDe;
                            objlabel.ghiChu    = item.ghiChu;
                            objlabel.maCode    = item.maCode;
                            objlabel.Module    = item.Module;
                            objlabel.A0008_ID  = obj.A0008_ID;
                            db.A0009.Add(objlabel);
                        }
                    }
                }
                db.SaveChanges();
                return(response);
            }
        }
コード例 #2
0
 public HttpResponseMessage R1_LabelGetByID(A0009 obj)
 {
     using (MeikoEntities db = new MeikoEntities())
     {
         db.Configuration.LazyLoadingEnabled   = false;
         db.Configuration.ProxyCreationEnabled = false;
         var response  = new HttpResponseMessage(HttpStatusCode.OK);
         var ListLabel = db.A0009.Where(x => x.maCode == obj.maCode).Select(x => new {
             x.A0009_ID,
             x.tenTieuDe,
             x.ghiChu,
             x.maCode,
             x.Module,
             x.A0008_ID,
             x.A0008.tenNgonNgu
         }).ToList();
         response.Content = new StringContent(JsonConvert.SerializeObject(ListLabel));
         response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
         return(response);
     }
 }
コード例 #3
0
 public HttpResponseMessage R2_AddLabel(A0009 label)
 {
     using (MeikoEntities db = new MeikoEntities())
     {
         db.Configuration.LazyLoadingEnabled   = false;
         db.Configuration.ProxyCreationEnabled = false;
         var response = new HttpResponseMessage(HttpStatusCode.OK);
         var Language = db.A0008.Where(x => x.tinhTrang == true).ToList();
         for (int i = 0; i < Language.Count; i++)
         {
             A0009 obj = new A0009();
             obj.A0009_ID  = helper.GenKey();
             obj.tenTieuDe = label.tenTieuDe;
             obj.ghiChu    = label.ghiChu;
             obj.maCode    = label.maCode;
             obj.Module    = label.Module;
             obj.A0008_ID  = Language[i].A0008_ID;
             db.A0009.Add(obj);
         }
         db.SaveChanges();
         return(response);
     }
 }