Example #1
0
        public bool RejectItemRequest(int Id)
        {
            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                int result        = 0;
                var query         = context.ItemRequestForms.Where(x => x.Id == Id && x.IsActive == true).FirstOrDefault();
                var ticketDetails = context.CodeHeaders.Include(x => x.CodeDetails)
                                    .Where(x => x.CodeHeaderName.Equals("Ticket Status"))
                                    .FirstOrDefault();

                if (query == null)
                {
                    return(false);
                }

                try
                {
                    query.StatusCd             = ticketDetails.CodeDetails.Where(x => x.CodeValue.Equals("Rejected")).Select(x => x.Id).FirstOrDefault();
                    context.Entry(query).State = EntityState.Modified;
                    result = context.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(false);
                }

                return(result > 0 ? true : false);
            }
        }
Example #2
0
        public string UpdateSupplier(Supplier sup)
        {
            try
            {
                using (OrmocIMSEntities context = new OrmocIMSEntities())
                {
                    var updateSup = context.Suppliers.Where(x => x.Id == sup.Id).FirstOrDefault();

                    if (updateSup == null)
                    {
                        return("No record found.");
                    }

                    updateSup.SupplierName    = sup.SupplierName;
                    updateSup.IsActive        = sup.IsActive;
                    updateSup.UpdateUserName  = sup.UpdateUserName;
                    updateSup.UpdateDttm      = sup.UpdateDttm;
                    updateSup.TelephoneNumber = sup.TelephoneNumber;
                    updateSup.Notes           = sup.Notes;
                    updateSup.Email           = sup.Email;
                    updateSup.SupplierAddress = sup.SupplierAddress;

                    context.Suppliers.Attach(updateSup);
                    context.Entry(updateSup).State = EntityState.Modified;
                    int result = context.SaveChanges();

                    return(result > 0 ? "Supplier updated." : "Error saving Supplier.");
                }
            }
            catch (Exception ex)
            {
                return("Internal error encountered.");
            }
        }
Example #3
0
        public string SaveToken(User saveToken)
        {
            try
            {
                using (OrmocIMSEntities context = new OrmocIMSEntities())
                {
                    var query = context.Users.Where(x => x.Id == saveToken.Id).FirstOrDefault();

                    query.Token          = saveToken.Token;
                    query.UpdateDttm     = DateTime.UtcNow;
                    query.UpdateUserName = "******";

                    context.Entry(query).State = System.Data.Entity.EntityState.Modified;
                    var result = context.SaveChanges();

                    if (result > 0)
                    {
                        return(saveToken.Token);
                    }
                    else
                    {
                        return("Error encountered during token save.");
                    }
                }
            }
            catch
            {
                return("Internal error encountered.");
            }
        }
Example #4
0
        public int AddNewTag(Tag tag)
        {
            Tag newTag = new Tag();

            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                int result = 0;
                var query  = context.Tags.Where(x => x.TagValue.Equals(tag.TagValue)).FirstOrDefault();

                if (query == null)
                {
                    newTag.TagValue       = tag.TagValue;
                    newTag.CreateUserName = "******";
                    newTag.CreateDttm     = DateTime.UtcNow;
                    newTag.UpdateUserName = "******";
                    newTag.UpdateDttm     = DateTime.UtcNow;

                    context.Tags.Add(newTag);
                    context.Entry(newTag).State = EntityState.Added;
                    result = context.SaveChanges();

                    return(result > 0 ? newTag.Id : 0);
                }
                else
                {
                    return(query.Id);
                }
            }
        }
Example #5
0
        public bool UpdateItemById(Item item)
        {
            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                var query = context.Items.Where(x => x.Id == item.Id).FirstOrDefault();

                if (query != null)
                {
                    query.ItemName       = item.ItemName;
                    query.LocationID     = item.LocationID;
                    query.CategoryID     = item.CategoryID;
                    query.SubCategoryID  = item.SubCategoryID;
                    query.BrandID        = item.BrandID;
                    query.Quantity       = item.Quantity;
                    query.MeasuredBy     = item.MeasuredBy;
                    query.ThresholdQty   = item.ThresholdQty;
                    query.Sku            = item.Sku;
                    query.Notes          = item.Notes;
                    query.UpdateUserName = item.UpdateUserName;
                    query.UpdateDttm     = item.UpdateDttm;

                    //for(int i = 0; i < query.ItemDetailMappings.Count; i++)
                    //{
                    //    query.ItemDetailMappings = item.ItemDetailMappings;
                    //}

                    context.Entry(query).State = EntityState.Modified;
                    int result = context.SaveChanges();

                    return(result > 0 ? true : false);
                }
            }

            return(false);
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cat"></param>
        /// <returns></returns>
        public Category InsertNewCategory(Category cat)
        {
            try
            {
                Category insertCat = new Category();

                insertCat.CategoryName   = cat.CategoryName;
                insertCat.IsActive       = cat.IsActive;
                insertCat.CreateUserName = cat.CreateUserName;
                insertCat.CreateDttm     = cat.CreateDttm;
                insertCat.UpdateUserName = cat.UpdateUserName;
                insertCat.UpdateDttm     = cat.UpdateDttm;

                using (OrmocIMSEntities context = new OrmocIMSEntities())
                {
                    context.Categories.Add(insertCat);
                    int result = context.SaveChanges();

                    return(result > 0 ? insertCat : new Category());
                }
            }
            catch (Exception ex)
            {
                return(new Category());
            }
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="brand"></param>
        /// <returns></returns>
        public Brand InsertNewBrand(Brand brand)
        {
            try
            {
                Brand insertBrand = new Brand();

                insertBrand.BrandName      = brand.BrandName;
                insertBrand.Notes          = brand.Notes;
                insertBrand.IsActive       = brand.IsActive;
                insertBrand.CreateUserName = brand.CreateUserName;
                insertBrand.CreateDttm     = brand.CreateDttm;
                insertBrand.UpdateUserName = brand.UpdateUserName;
                insertBrand.UpdateDttm     = brand.UpdateDttm;

                using (OrmocIMSEntities context = new OrmocIMSEntities())
                {
                    context.Brands.Add(insertBrand);
                    int result = context.SaveChanges();

                    return(result > 0 ? insertBrand : new Brand());
                }
            }
            catch (Exception ex)
            {
                return(new Brand());
            }
        }
Example #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cat"></param>
        /// <returns></returns>
        public string UpdateCategoryDetails(Category cat)
        {
            try
            {
                using (OrmocIMSEntities context = new OrmocIMSEntities())
                {
                    Category updateCat = context.Categories.Where(x => x.Id == cat.Id && x.IsActive == true).FirstOrDefault();

                    if (updateCat == null)
                    {
                        return("No record found.");
                    }

                    updateCat.CategoryName   = cat.CategoryName;
                    updateCat.IsActive       = cat.IsActive;
                    updateCat.UpdateUserName = cat.UpdateUserName;
                    updateCat.UpdateDttm     = cat.UpdateDttm;

                    context.Categories.Attach(updateCat);
                    context.Entry(updateCat).State = System.Data.Entity.EntityState.Modified;
                    int result = context.SaveChanges();

                    return(result > 0 ? "Category updated." : "Error saving Category.");
                }
            }
            catch (Exception ex)
            {
                return("Internal error encountered.");
            }
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sub"></param>
        /// <returns></returns>
        public string UpdateSubCategoryDetails(SubCategory sub)
        {
            try
            {
                using (OrmocIMSEntities context = new OrmocIMSEntities())
                {
                    var updateSub = context.SubCategories.Where(x => x.Id == sub.Id && x.IsActive == true).FirstOrDefault();

                    if (updateSub == null)
                    {
                        return("No record found.");
                    }

                    updateSub.CategoryID      = sub.CategoryID;
                    updateSub.SubCategoryName = sub.SubCategoryName;
                    updateSub.IsActive        = sub.IsActive;
                    updateSub.UpdateUserName  = sub.UpdateUserName;
                    updateSub.UpdateDttm      = sub.UpdateDttm;

                    context.SubCategories.Attach(updateSub);
                    context.Entry(updateSub).State = EntityState.Modified;
                    int result = context.SaveChanges();

                    return(result > 0 ? "SubCategory updated." : "Error saving SubCategory.");
                }
            }
            catch (Exception ex)
            {
                return("Internal error encountered.");
            }
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sub"></param>
        /// <returns></returns>
        public SubCategory InsertNewSubCategory(SubCategory sub)
        {
            try
            {
                SubCategory insertSub = new SubCategory();

                insertSub.CategoryID      = sub.CategoryID;
                insertSub.SubCategoryName = sub.SubCategoryName;
                insertSub.IsActive        = sub.IsActive;
                insertSub.CreateUserName  = sub.CreateUserName;
                insertSub.CreateDttm      = sub.CreateDttm;
                insertSub.UpdateUserName  = sub.UpdateUserName;
                insertSub.UpdateDttm      = sub.UpdateDttm;

                using (OrmocIMSEntities context = new OrmocIMSEntities())
                {
                    context.SubCategories.Add(insertSub);
                    int result = context.SaveChanges();

                    return(result > 0 ? insertSub : new SubCategory());
                }
            }
            catch (Exception ex)
            {
                return(new SubCategory());
            }
        }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="brand"></param>
        /// <returns></returns>
        public string UpdateBrandDetails(Brand brand)
        {
            try
            {
                using (OrmocIMSEntities context = new OrmocIMSEntities())
                {
                    Brand updateBrand = context.Brands.Where(x => x.Id == brand.Id).FirstOrDefault();

                    if (updateBrand == null)
                    {
                        return("No record found.");
                    }

                    updateBrand.BrandName      = brand.BrandName;
                    updateBrand.Notes          = brand.Notes;
                    updateBrand.IsActive       = brand.IsActive;
                    updateBrand.UpdateUserName = brand.UpdateUserName;
                    updateBrand.UpdateDttm     = brand.UpdateDttm;

                    context.Brands.Attach(updateBrand);
                    context.Entry(updateBrand).State = System.Data.Entity.EntityState.Modified;
                    int result = context.SaveChanges();

                    return(result > 0 ? "Brand updated." : "Error saving Brand.");
                }
            }
            catch
            {
                return("Internal error encountered.");
            }
        }
Example #12
0
        public Supplier CreateNewSupplier(Supplier sup)
        {
            try
            {
                Supplier createSupplier = new Supplier();

                createSupplier.SupplierName    = sup.SupplierName;
                createSupplier.SupplierAddress = sup.SupplierAddress;
                createSupplier.TelephoneNumber = sup.TelephoneNumber;
                createSupplier.Email           = sup.Email;
                createSupplier.Notes           = sup.Notes;
                createSupplier.IsActive        = sup.IsActive;
                createSupplier.CreateUserName  = sup.CreateUserName;
                createSupplier.CreateDttm      = sup.CreateDttm;
                createSupplier.UpdateDttm      = sup.UpdateDttm;
                createSupplier.UpdateUserName  = sup.UpdateUserName;

                using (OrmocIMSEntities context = new OrmocIMSEntities())
                {
                    context.Suppliers.Add(createSupplier);
                    int result = context.SaveChanges();

                    return(result > 0 ? createSupplier : new Supplier());
                }
            }
            catch (Exception ex)
            {
                return(new Supplier());
            }
        }
Example #13
0
        public ItemRequestForm InsertNewItemRequest(ItemRequestForm itemRequest)
        {
            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                context.ItemRequestForms.Add(itemRequest);
                context.Entry(itemRequest).State = EntityState.Added;
                int result = context.SaveChanges();

                return(result > 0 ? itemRequest : new ItemRequestForm());
            }
        }
Example #14
0
        public bool DeleteItemFromItemRequest(int id)
        {
            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                var query = context.ItemRequestFormMappings.Where(x => x.Id == id).FirstOrDefault();

                context.Entry(query).State = EntityState.Deleted;
                int result = context.SaveChanges();

                return(result > 0 ? true : false);
            }
        }
Example #15
0
        public bool AddTaggingByItemId(int tagId, int itemId)
        {
            TagsMapping newTag = new TagsMapping();
            int         result = 0;

            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                var query = context.TagsMappings.Where(x => x.TagID == tagId && x.ItemID == itemId).FirstOrDefault();

                if (query == null)
                {
                    newTag.TagID          = tagId;
                    newTag.ItemID         = itemId;
                    newTag.IsActive       = true;
                    newTag.CreateUserName = "******";
                    newTag.CreateDttm     = DateTime.UtcNow;
                    newTag.UpdateUserName = "******";
                    newTag.UpdateDttm     = DateTime.UtcNow;

                    context.Entry(newTag).State = EntityState.Added;
                    result = context.SaveChanges();

                    return(result > 0 ? true : false);
                }
                else
                {
                    query.IsActive       = true;
                    query.UpdateUserName = "******";
                    query.UpdateDttm     = DateTime.UtcNow;

                    context.Entry(query).State = EntityState.Modified;
                    result = context.SaveChanges();

                    return(result > 0 ? true : false);
                }
            }
        }
Example #16
0
        public bool AttachItemToItemRequest(ItemRequestFormMapping item)
        {
            if (item == null)
            {
                return(false);
            }

            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                context.Entry(item).State = EntityState.Added;
                int result = context.SaveChanges();

                return(result > 0 ? true : false);
            }
        }
Example #17
0
        public bool InsertNewItemDetailMapping(List <ItemDetailMapping> itemDetail)
        {
            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                int result = 0;

                for (int i = 0; i < itemDetail.Count; i++)
                {
                    context.ItemDetailMappings.Add(itemDetail[i]);
                    context.Entry(itemDetail[i]).State = EntityState.Added;
                    result = result + context.SaveChanges();
                }

                return(result == itemDetail.Count ? true : false);
            }
        }
Example #18
0
        public bool UpdateItemStatusById(int id, string StatusCd)
        {
            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                var item       = context.Items.Where(x => x.Id == id).FirstOrDefault();
                var codeDetail = context.CodeDetails.Where(x => x.CodeValue.ToLower().Equals(StatusCd)).FirstOrDefault();

                item.StatusCd       = codeDetail.Id;
                item.UpdateUserName = "******";
                item.UpdateDttm     = DateTime.UtcNow;

                context.Entry(item).State = EntityState.Modified;
                int result = context.SaveChanges();

                return(result > 0 ? true : false);
            }
        }
Example #19
0
        public bool UpdateItemRequestById(ItemRequestForm itemRequest)
        {
            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                var item = context.ItemRequestForms.Where(x => x.Id == itemRequest.Id).FirstOrDefault();

                item.Id             = itemRequest.Id;
                item.Title          = itemRequest.Title;
                item.UpdateDttm     = itemRequest.UpdateDttm;
                item.UpdateUserName = itemRequest.UpdateUserName;

                context.Entry(item).State = EntityState.Modified;
                int result = context.SaveChanges();

                return(result > 0 ? true : false);
            }
        }
Example #20
0
        public bool UpdateItemDetailMappingByItemId(ItemDetailMapping item)
        {
            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                int result = 0;

                int itemDetailMappingId = item.Id;

                var query = context.ItemDetailMappings.Where(x => x.Id == itemDetailMappingId).FirstOrDefault();

                query.ItemDetailValue = item.ItemDetailValue;
                query.IsActive        = item.IsActive;
                query.UpdateUserName  = item.UpdateUserName;
                query.UpdateDttm      = item.UpdateDttm;

                context.Entry(query).State = EntityState.Modified;
                result = result + context.SaveChanges();

                return(result > 0 ? true : false);
            }
        }
Example #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="brandId"></param>
        /// <returns></returns>
        public string DeleteBrand(int brandId)
        {
            try
            {
                using (OrmocIMSEntities context = new OrmocIMSEntities())
                {
                    var selectedBrand = context.Brands.Where(x => x.Id == brandId && x.IsActive == true).FirstOrDefault();

                    if (selectedBrand != null)
                    {
                        selectedBrand.IsActive       = false;
                        selectedBrand.UpdateUserName = "******";
                        selectedBrand.UpdateDttm     = DateTime.UtcNow;

                        context.Brands.Attach(selectedBrand);
                        context.Entry(selectedBrand).State = System.Data.Entity.EntityState.Modified;
                        var result = context.SaveChanges();

                        if (result > 0)
                        {
                            return("Brand deleted.");
                        }
                        else
                        {
                            return("Error encountered during save.");
                        }
                    }
                    else
                    {
                        return("No record found.");
                    }
                }
            }
            catch (Exception ex)
            {
                return("Internal error encountered.");
            }
        }
Example #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="subCategoryId"></param>
        /// <returns></returns>
        public string DeleteSubCategory(int subCategoryId)
        {
            try
            {
                using (OrmocIMSEntities context = new OrmocIMSEntities())
                {
                    var selectedSub = context.SubCategories.Where(x => x.Id == subCategoryId && x.IsActive == true).FirstOrDefault();

                    if (selectedSub != null)
                    {
                        selectedSub.IsActive       = false;
                        selectedSub.UpdateUserName = "******";
                        selectedSub.UpdateDttm     = DateTime.UtcNow;

                        context.SubCategories.Attach(selectedSub);
                        context.Entry(selectedSub).State = EntityState.Modified;
                        var result = context.SaveChanges();

                        if (result > 0)
                        {
                            return("SubCategory deleted.");
                        }
                        else
                        {
                            return("Error encountered during save.");
                        }
                    }
                    else
                    {
                        return("No record found.");
                    }
                }
            }
            catch (Exception ex)
            {
                return("Internal error encountered.");
            }
        }
Example #23
0
        public bool RemoveTaggingByItemId(int itemId, int tagId)
        {
            int result = 0;

            using (OrmocIMSEntities context = new OrmocIMSEntities())
            {
                var query = context.TagsMappings.Where(x => x.ItemID == itemId && x.TagID == tagId).FirstOrDefault();

                if (query != null)
                {
                    query.IsActive       = false;
                    query.UpdateUserName = "******";
                    query.UpdateDttm     = DateTime.UtcNow;

                    context.Entry(query).State = EntityState.Modified;
                    result = context.SaveChanges();

                    return(result > 0 ? true : false);
                }
            }

            return(false);
        }