Beispiel #1
0
 public static CategoryDto createCategoryDTO(Category obj)
 {
     CategoryDto cat = new CategoryDto();
     cat.CategoryId = obj.CategoryId;
     cat.CategoryName = obj.CategoryName;
     cat.CategoryDescription = obj.CategoryDescription;
     return cat;
 }
Beispiel #2
0
 public static Category createCategory(String CategoryId, String CategoryName, String CategoryDescription)
 {
     Category obj = new Category();
     obj.CategoryId = CategoryId;
     obj.CategoryName = CategoryName;
     obj.CategoryDescription = CategoryDescription;
     return obj;
 }
        public Category selectCategoryById(Category obj)
        {
            NewRecruiteeBankContext db = new NewRecruiteeBankContext();

            try
            {

                return db.Categories.SqlQuery("dbo.SelectCategoryById @CategoryId='" + obj.CategoryId.ToString() + "'").Single();
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        public Boolean insertCategory(Category obj)
        {
            using (NewRecruiteeBankContext db = new NewRecruiteeBankContext())
            {
                try
                {
                    db.Categories.Add(obj);
                    db.SaveChanges();
                    return true;
                }
                catch (Exception ex)
                {
                    return false;
                }

            }
        }
        public Boolean deleteCategory(Category obj)
        {
            using (NewRecruiteeBankContext db = new NewRecruiteeBankContext())
            {
                try
                {
                    Category category = db.Categories.SqlQuery("dbo.SelectCategoryById @CategoryId='" + obj.CategoryId.ToString() + "'").Single();

                    if (category != null)
                    {
                        db.Categories.Remove(category);
                        #region Database Submission

                        try
                        {
                            db.SaveChanges();
                            return true;
                        }
                        catch (Exception ex)
                        {
                            return false;
                        }

                        #endregion
                    }
                    else
                    {
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    return false;
                }
            }
        }