Exemplo n.º 1
0
        public HttpResponseMessage UploadFile(string id)
        {
            var pathToSql = " http://localhost:58516/UploadFiles/ ";
            var allPath   = " ";
            HttpResponseMessage response = new HttpResponseMessage();
            var abc         = Request.Properties.Values;
            var httpRequest = HttpContext.Current.Request;

            foreach (string file in httpRequest.Files)
            {
                pathToSql = " http://localhost:58516/UploadFiles/";
                var postedFile    = httpRequest.Files[file];
                var directoryPath = HttpContext.Current.Server.MapPath(" ~/ UploadFiles / ");
                Directory.CreateDirectory(directoryPath + id);
                allPath = directoryPath + id + "/" + postedFile.FileName;
                postedFile.SaveAs(allPath);
                pathToSql += id + "/ " + postedFile.FileName;
                using (HMO_PROGECTEntities db = new HMO_PROGECTEntities())
                {
                    var product = db.PRODUCTS_TBL.FirstOrDefault(u => u.productId.ToString() == id);
                    product.imag = pathToSql;
                    db.SaveChanges();
                }
            }
            return(response);
        }
Exemplo n.º 2
0
 public static void Create(USERS_DTO user)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         USERS_TBL newUser = ctx.USERS_TBL.Where(u => u.userId == user.userId || u.userName == user.userName).FirstOrDefault();
         if (newUser == null)
         {
             ctx.USERS_TBL.Add(new USERS_TBL()
             {
                 firstName   = user.firstName,
                 lastName    = user.lastName,
                 userName    = user.userName,
                 password    = user.password,
                 hmoId       = user.hmoId,
                 mail        = user.mail,
                 telephone   = user.telephone,
                 adress      = user.adress,
                 tz          = user.tz,
                 requestForm = user.requestForm,
                 isActive    = true,
                 isConfirm   = false
             });
             ctx.SaveChanges();
         }
         else
         {
             throw new Exception("is exsist");
         }
     }
 }
Exemplo n.º 3
0
 //public static PRICE price;
 public static PRODUCTS_DTO getProductsById(int id)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         return(ProductsCRUD.ReadById(ctx, id));
     }
 }
Exemplo n.º 4
0
 public static PRICE_DTO getPricetById(int id)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         return(priceCRUD.ReadById(ctx, id));
     }
 }
Exemplo n.º 5
0
 public static REQUEST_DTO getRequestById(int id)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         return(RequestCRUD.ReadById(ctx, id));
     }
 }
Exemplo n.º 6
0
 public static USERS_DTO getUserById(int id)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         return(UserCRUD.ReadById(ctx, id));
     }
 }
Exemplo n.º 7
0
 public PRODUCTS_TBL compaireProductPrice(PRODUCTS_TBL product)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         return(null);
     }
 }
Exemplo n.º 8
0
 //read by id
 public static HMO_TBL GetHmoById(int id)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         return(ctx.HMO_TBL.Where(i => i.hmoId == id).FirstOrDefault());
     }
 }
Exemplo n.º 9
0
 //create
 public static void Create(INSURANCE_DTO insurence)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         ctx.INSURANCE_TBL.Add(new INSURANCE_TBL());
         ctx.SaveChanges();
     }
 }
Exemplo n.º 10
0
 //delete
 public static void delete(PRICE_DTO price)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         ctx.PRICEs.Remove(ctx.PRICEs.FirstOrDefault(u => u.priceId == price.priceId));
         ctx.SaveChanges();
     }
 }
Exemplo n.º 11
0
 //read user by hmo:
 public static HMO_TBL ReadUserByHmo(USERS_TBL user)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         HMO_TBL hmo = ctx.HMO_TBL.Where(u => u.hmoId == user.hmoId).FirstOrDefault();
         return(hmo);
     }
 }
Exemplo n.º 12
0
 //create
 public static void Create(HMO_PROGECTEntities ctx, HMO_TBL hmo)
 {
     ctx.HMO_TBL.Add(new HMO_TBL()
     {
         hmoName = hmo.hmoName,
         hmoMail = hmo.hmoMail
     });
     ctx.SaveChanges();
 }
Exemplo n.º 13
0
 public static void changeConfirm(int requestid)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         var x = ctx.REQUEST_TBL.FirstOrDefault(u => u.requestId == requestid);
         x.requestStatus = 2;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 14
0
        //readByCategoryId
        public static List <PRODUCTS_DTO> GetProductByCategoryId(HMO_PROGECTEntities ctx, int categoryId)
        {
            var list = ctx.PRODUCTS_TBL.Where(i => i.categoryId == categoryId).ToList();
            var dtoL = new List <PRODUCTS_DTO>();

            list.ForEach(f => {
                dtoL.Add(Casting.PRODUCTS_Casting.CastToDTO(f));
            });
            return(dtoL);
        }
Exemplo n.º 15
0
 public IHttpActionResult Delete(HMO_PROGECTEntities ctx, HMO_TBL hmo)
 {
     try
     {
         HmoCRUD.delete(ctx, hmo);
         return(Ok());
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }
Exemplo n.º 16
0
 public static AGE_DTO getRange(int age)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         AGE_TBL ages = ctx.AGE_TBL.Where(p => p.begins <= age && p.ends <= age).FirstOrDefault();
         if (ages != null)
         {
             return(AGE_Casting.CastToDTO(ages));
         }
         return(null);
     }
 }
Exemplo n.º 17
0
 public static HMO_TBL GetHmoByProduct(PRODUCTS_TBL product)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         INSURANCE_TBL insurance = InsuranceModule.GetProductInsurance(product);
         if (insurance != null)
         {
             HMO_TBL hmo = ctx.HMO_TBL.Where(u => u.hmoId == insurance.hmoId).FirstOrDefault();
         }
         return(null);
     }
 }
Exemplo n.º 18
0
 //public static List<HMO_TBL> GetAllHmos()
 //{
 //    using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
 //    {
 //        return HmoCRUD.GetAllHmos(ctx);
 //    }
 //}
 public static List <HMO_DTO> GetAllHmo()
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         var            hmoList = HmoCRUD.GetAllHmos(ctx);
         List <HMO_DTO> hmos    = new List <HMO_DTO>();
         foreach (var hmo in hmoList)
         {
             hmos.Add(HMO_Casting.CastToDTO(hmo));
         }
         return(hmos);
     }
 }
Exemplo n.º 19
0
 public static void Update(PRICE_DTO price)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         var x = ctx.PRICEs.FirstOrDefault(u => u.priceId == price.priceId);
         x.insuranceId = price.insuranceId;
         x.INSURANCE_TBL.insuranceName = price.insuranceName;
         x.priceText = price.priceText;
         x.discount  = price.discount;
         //x.AGE_TBL.begins = price.ageRange;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 20
0
 public static PRICE GetProductPrice(PRODUCTS_TBL product)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         var productdetail = ProductsCRUD.ReadById(ctx, product.productId);
         if (productdetail != null)
         {
             PRICE price = ctx.PRICEs.Where(u => u.productId == product.productId).FirstOrDefault();
             return(price);
         }
         return(null);
     }
 }
Exemplo n.º 21
0
 public static List <AGE_DTO> GetAllAgeRange()
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         var            AgeRangeList = AgeCRUD.GetAllAgeRange(ctx);
         List <AGE_DTO> ages         = new List <AGE_DTO>();
         foreach (var age in AgeRangeList)
         {
             ages.Add(AGE_Casting.CastToDTO(age));
         }
         return(ages);
     }
 }
Exemplo n.º 22
0
 public static List <CATEGORIES_DTO> GetAllCategories()
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         var categoriesList = CategoryCRUD.GetAllCategories(ctx);
         List <CATEGORIES_DTO> categories = new List <CATEGORIES_DTO>();
         foreach (var category in categoriesList)
         {
             categories.Add(CATEGORIES_Casting.CastToDTO(category));
         }
         return(categories);
     }
 }
Exemplo n.º 23
0
        public static double?getInsurancePrice(INSURANCE_TBL insurance)
        {
            using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
            {
                var selectedInsurance = InsuranceCRUD.Read(insurance.insuranceId);
                if (selectedInsurance != null)
                {
                    return(selectedInsurance.InsurancePrice);
                }

                return(null);
            }
        }
Exemplo n.º 24
0
 private static void AddChildernForNode(HMO_PROGECTEntities db, CategoryTree categoryTree, List <CATEGORIES_TBL> allCategoriesList)
 {
     foreach (var item in allCategoriesList.Where(i => i.parentCategory == categoryTree.id).ToList())
     {
         var category = new CategoryTree()
         {
             id       = item.categoriesId,
             name     = item.categoryName,
             children = new List <CategoryTree>()
         };
         AddChildernForNode(db, category, allCategoriesList);
         categoryTree.children.Add(category);
     }
 }
Exemplo n.º 25
0
 public IHttpActionResult GetAll(int id)
 {
     try
     {
         using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
         {
             ProductsModule.getProductByKriterion(id);
         }
         return(Ok());
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }
Exemplo n.º 26
0
        public static List <CATEGORIES_DTO> GetAllSubCategory(int id)
        {
            using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
            {
                var categoriesList  = CategoryCRUD.GetAllCategories(ctx);
                var subCategoryList = categoriesList.Where(u => u.parentCategory == id).ToList();
                List <CATEGORIES_DTO> categories = new List <CATEGORIES_DTO>();

                foreach (var category in subCategoryList)
                {
                    categories.Add(CATEGORIES_Casting.CastToDTO(category));
                }
                return(categories);
            }
        }
Exemplo n.º 27
0
 public List <CategoryTree> GetCategoryTree()
 {
     using (HMO_PROGECTEntities db = new HMO_PROGECTEntities())
     {
         List <CategoryTree> CategoryTreeList = new List <CategoryTree>();
         CategoryTree        categoryTree     = new CategoryTree()
         {
             id       = 0,
             name     = "קטגוריות",
             children = new List <CategoryTree>()
         };
         var allCategoriesList = db.CATEGORIES_TBL.ToList();
         AddChildernForNode(db, categoryTree, allCategoriesList);
         CategoryTreeList.Add(categoryTree);
         return(CategoryTreeList);
     }
 }
Exemplo n.º 28
0
 //create
 public static int Create(PRODUCTS_DTO product)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         // ctx.PRODUCTS_TBL.Add(new PRODUCTS_TBL { name = product.name, description = product.description, categoryId = product.categoryId });
         PRODUCTS_TBL newProduct = new PRODUCTS_TBL()
         {
             name        = product.name,
             description = product.description,
             categoryId  = product.categoryId,
             imag        = product.imag
         };
         ctx.PRODUCTS_TBL.Add(newProduct);
         ctx.SaveChanges();
         var lastProduct = ctx.PRODUCTS_TBL.LastOrDefault();
         return(lastProduct.productId);
     }
 }
Exemplo n.º 29
0
 public static CategoryDetails GetCategoryDetailsById(int id)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         var categoryDetails = new CategoryDetails();
         var category        = CategoryCRUD.GetCategoryById(ctx, id);
         if (category != null)
         {
             categoryDetails.Id   = category.categoriesId;
             categoryDetails.Name = category.categoryName;
             var productList = ProductsCRUD.GetProductByCategoryId(ctx, id);
             foreach (var product in productList)
             {
                 categoryDetails.ProductsList.Add(product);
             }
             return(categoryDetails);
         }
         return(null);
     }
 }
Exemplo n.º 30
0
 public static void Update(USERS_DTO user)
 {
     using (HMO_PROGECTEntities ctx = new HMO_PROGECTEntities())
     {
         var x = ctx.USERS_TBL.FirstOrDefault(u => u.userId == user.userId);
         x.userName  = user.userName;
         x.tz        = user.tz;
         x.lastName  = user.lastName;
         x.firstName = user.firstName;
         x.adress    = user.adress;
         x.isAdmin   = user.isAdmin;
         x.telephone = user.telephone;
         x.password  = user.password;
         x.mail      = user.mail;
         x.isConfirm = user.isConfirm;
         x.isActive  = user.isActive;
         x.hmoId     = user.hmoId;
         ctx.SaveChanges();
     }
 }