示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] ProviderCategory providerCategory)
        {
            if (id != providerCategory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(providerCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProviderCategoryExists(providerCategory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(providerCategory));
        }
示例#2
0
        protected void repeaterServices_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName.ToLower())
            {
            case "edit":

                #region -- Lấy thông tin dịch vụ

                ActiveTourRegion        = Module.ProviderCategoryGetById(Convert.ToInt32(e.CommandArgument));
                textBoxServiceName.Text = ActiveTourRegion.Name;
                textBoxOrder.Text       = ActiveTourRegion.Order.ToString();
                //if (ActiveTourRegion.Parent != null)
                //{
                //    ddlParent.SelectedValue = ActiveTourRegion.Parent.Id.ToString();
                //}
                //else
                //{
                //    ddlParent.SelectedIndex = 0;
                //}

                #endregion

                btnDelete.Visible   = true;
                btnDelete.Enabled   = true;
                labelFormTitle.Text = ActiveTourRegion.Name;
                break;

            default:
                break;
            }
        }
示例#3
0
        protected void repeaterServices_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            ProviderCategory service = e.Item.DataItem as ProviderCategory;

            if (service != null)
            {
                using (LinkButton linkServiceEdit = e.Item.FindControl("linkButtonServiceEdit") as LinkButton)
                {
                    if (linkServiceEdit != null)
                    {
                        // Gán text và command argument, điều này cũng có thể làm ngay trên aspx
                        linkServiceEdit.Text            = service.Name;
                        linkServiceEdit.CommandArgument = service.Id.ToString();
                    }
                }

                //Repeater repeaterSubCategories = e.Item.FindControl("repeaterSubCategories") as Repeater;
                //if (repeaterSubCategories != null)
                //{
                //    if (service.Children.Count > 0)
                //    {
                //        repeaterSubCategories.DataSource = service.Children;
                //        repeaterSubCategories.DataBind();
                //    }
                //}
            }
        }
示例#4
0
        public void SaveProviderCategory(Provider provider, ProviderCategory category)
        {
            Provider_Category link = new Provider_Category();

            link.Provider = provider;
            link.Category = category;
            _commonDao.SaveObject(link);
        }
示例#5
0
 public CreateProviderCategoryViewModel MapToCreateProviderCategoryViewModel(ProviderCategory providerCategory)
 {
     return(new CreateProviderCategoryViewModel
     {
         Id = providerCategory.Id,
         Name = providerCategory.Name
     });
 }
示例#6
0
 /// <summary>
 /// Khi ấn nút Add New, đưa trạng thái trở về thêm mới, xóa các textbox
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     ActiveTourRegion        = new ProviderCategory();
     textBoxServiceName.Text = String.Empty;
     labelFormTitle.Text     = Resources.labelNewTourRegion;
     btnDelete.Visible       = false;
     btnDelete.Enabled       = false;
     BindParent();
 }
示例#7
0
 public void DeleteCategory(ProviderCategory category)
 {
     foreach (var provider in _providerRepository.GetBy(x => x.Category.Id == category.Id))
     {
         Delete(provider);
     }
     _categoryRepository.Delete(category);
     _contextProvider.CommitChanges();
 }
示例#8
0
 public void CreateCategory(ProviderCategory providerCategory)
 {
     if (_categoryRepository.GetBy(x => x.Name == providerCategory.Name).Any())
     {
         return;
     }
     _categoryRepository.Create(providerCategory);
     _contextProvider.CommitChanges();
 }
        public void Create_CreatedCategory_ThrowsNoExceptions()
        {
            var category = new ProviderCategory
            {
                Name = "New category"
            };

            _initializer.ProviderCategoryRepository.Create(category);
            Assert.That(() => _initializer.CommitProvider.CommitChanges(), Throws.Nothing);
        }
        public void Create_CategoryNotValid_ThrowsException()
        {
            var category = new ProviderCategory
            {
                Name = null
            };

            _initializer.ProviderCategoryRepository.Create(category);
            Assert.That(() => _initializer.CommitProvider.CommitChanges(), Throws.Exception);
        }
示例#11
0
文件: Provider.cs 项目: wangn6/rep2
 public static IList<Provider> GetProvidersByCategory(ProviderCategory categroy)
 {
     using (var context = new ES1AutomationEntities())
     {
         return (
                     from provider in context.Providers.Where(p => p.Category == (int)categroy)
                     select provider
                ).ToList();
     }
 }
示例#12
0
        public async Task <IActionResult> Create([Bind("Id,Name")] ProviderCategory providerCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(providerCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(providerCategory));
        }
示例#13
0
        public void CreateCategory_CreatedCategory_ThrowsNoException()
        {
            var expected = new ProviderCategory
            {
                Name = "New category"
            };

            Assert.That(() => _initializer.ProviderService.CreateCategory(expected), Throws.Nothing);
            var actual = _initializer.ProviderCategoryRepository.GetBy(x => x.Name == expected.Name).Single();

            Assert.AreEqual(expected, actual);
        }
示例#14
0
        /// <summary>
        /// Gets the hash code for this object.
        /// </summary>
        /// <returns>
        /// The hash code for this object.
        /// </returns>
        /// <remarks>
        /// * CA2218:
        ///   * If two objects are equal in value based on the Equals override, they must both return the same value for calls
        ///     to GetHashCode.
        ///   * GetHashCode must be overridden whenever Equals is overridden.
        /// * It is fine if the value overflows.
        /// </remarks>
        public override int GetHashCode()
        {
            int result = GlobalId.GetHashCode() +
                         ParentDealId.GetHashCode() +
                         ProviderId.GetHashCode() +
                         MerchantId.GetHashCode() +
                         ProviderCategory.GetHashCode() +
                         StartDate.GetHashCode() +
                         EndDate.GetHashCode() +
                         Amount.GetHashCode() +
                         Count.GetHashCode() +
                         UserLimit.GetHashCode() +
                         MinimumPurchase.GetHashCode() +
                         MaximumDiscount.GetHashCode() +
                         DealStatusId.GetHashCode();

            if (MerchantName != null)
            {
                result += MerchantName.GetHashCode();
            }

            if (Currency != null)
            {
                result += Currency.GetHashCode();
            }

            if (DiscountSummary != null)
            {
                result += DiscountSummary.GetHashCode();
            }

            foreach (PartnerDealInfo partnerDealInfo in PartnerDealInfoList)
            {
                result += partnerDealInfo.GetHashCode();
            }

            if (DayTimeRestrictions != null)
            {
                result += DayTimeRestrictions.GetHashCode();
            }

            return(result);
        }
示例#15
0
 /// <summary>
 /// Khi ấn nút Save, lưu Service nếu đang edit, insert nếu đang thêm mới
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     ActiveTourRegion.Name  = textBoxServiceName.Text;
     ActiveTourRegion.Order = Convert.ToInt32(textBoxOrder.Text);
     //if (ddlParent.SelectedIndex > 0 && ActiveTourRegion.Id.ToString() != ddlParent.SelectedValue)
     //{
     //    ActiveTourRegion.Parent = Module.TourRegionGetById(Convert.ToInt32(ddlParent.SelectedValue));
     //}
     //else
     //{
     //    ActiveTourRegion.Parent = null;
     //}
     // Kiểm tra trong View State
     Module.SaveOrUpdate(ActiveTourRegion);
     ActiveTourRegion            = ActiveTourRegion;
     labelFormTitle.Text         = ActiveTourRegion.Name;
     repeaterServices.DataSource = Module.ProviderCategoryGetAll(); //Module.TourRegionGetAllRoot();
     repeaterServices.DataBind();
 }
示例#16
0
 protected void rptCategory_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.DataItem is ProviderCategory)
     {
         ProviderCategory category    = (ProviderCategory)e.Item.DataItem;
         CheckBox         chkCategory = e.Item.FindControl("chkCategory") as CheckBox;
         if (chkCategory != null)
         {
             chkCategory.Text = category.Name;
             if (_hashtable[category.Id] != null)
             {
                 chkCategory.Checked = true;
             }
             else
             {
                 chkCategory.Checked = false;
             }
         }
     }
 }
 public static List <IOASISProvider> GetProvidersOfCategory(ProviderCategory category)
 {
     return(_registeredProviders.Where(x => x.ProviderCategory == category).ToList());
 }
        public void Delete_CategoryNotFound_ThrowsException()
        {
            var category = new ProviderCategory();

            Assert.That(() => _initializer.ProviderCategoryRepository.Delete(category), Throws.Exception);
        }
示例#19
0
        public IList <ProviderVm> QueryallProviderforJson(out int totalRecord, out int totalcountinresult, string search, int start, int lenght,
                                                          string sortColumn, string sortOrder, string srcProviderName, string scrAddress, int state, int zone, bool useDate,
                                                          DateTime scrFromDate, DateTime scrToDate, string scrUsers, int otherFilters, int plantype, int Zone, int ServiceType, int BoundByType, int category, bool delistshow)
        {
            IQueryOver <Provider, Provider> query = _session.QueryOver <Provider>().Where(x => x.IsDeleted == false && (x.AuthorizationStatus == 0 || x.AuthorizationStatus == 2));

            if (!delistshow)
            {
                query.Where(x => x.isDelisted == false);
            }
            List <ProviderVm> response = new List <ProviderVm>();

            if (!string.IsNullOrEmpty(srcProviderName))
            {
                srcProviderName = "%" + srcProviderName + "%";
                query.AndRestrictionOn(x => x.Name).IsInsensitiveLike(srcProviderName);
            }

            if (!string.IsNullOrEmpty(scrAddress))
            {
                scrAddress = "%" + scrAddress + "%";
                query.AndRestrictionOn(x => x.Address).IsInsensitiveLike(scrAddress);
            }

            if (state > 0)
            {
                query.Where(x => x.State.Id == state);
            }

            if (category > -1)
            {
                ProviderCategory conv = (ProviderCategory)category;
                query.Where(x => x.Category == conv);
            }

            if (zone > 0)
            {
                query.Where(x => x.State.Zone == zone);
            }
            if (useDate)
            {
                DateTime datete = Convert.ToDateTime(scrToDate);

                int dd    = datete.Day;
                int month = datete.Month;
                int year  = datete.Year;

                string   time    = "23:59";
                DateTime enddate = Convert.ToDateTime(string.Format("{0}/{1}/{2} {3}", month, dd, year, time));
                query.Where(Restrictions.On <Enrollee>(a => a.CreatedOn).IsBetween(scrFromDate).And(enddate));
            }

            if (!string.IsNullOrEmpty(scrUsers))
            {
                query.Where(x => x.CreatedBy == scrUsers);
            }
            if (Zone > -1)
            {
                List <int> states = (List <int>)_session.QueryOver <State>().Where(x => x.Zone == Zone).SelectList(a => a.Select(p => p.Id)).List <int>();


                //var ids = new List<int> { 1, 2, 5, 7 };
                //var query2 = _session.QueryOver<Provider>().Where(x => x.IsDeleted == false && x.AuthorizationStatus == 2 );

                query
                .WhereRestrictionOn(w => w.State).IsIn(states);
            }

            if (ServiceType > -1)
            {
                string serviceid = "%" + Convert.ToString(ServiceType) + "%";

                IQueryOver <Provider, Provider> query2 = _session.QueryOver <Provider>().Where(x => x.IsDeleted == false && x.AuthorizationStatus == 2);
                query2.AndRestrictionOn(x => x.Providerservices).IsInsensitiveLike(ServiceType);
                List <int> output = new List <int>();
                int        count  = query2.RowCount();
                for (int i = 0; i < count; i++)
                {
                    Provider item        = query2.Skip(i).Take(1).SingleOrDefault();
                    string[] allservices = item.Providerservices.Split(',');
                    output.AddRange(from service in allservices where service.Trim() == Convert.ToString(ServiceType) select item.Id);
                }

                query.WhereRestrictionOn(bp => bp.Id)
                .IsIn(output);
            }
            if (plantype > -1)
            {
                string planid = "%" + Convert.ToString(plantype) + "%";

                IQueryOver <Provider, Provider> query2 = _session.QueryOver <Provider>().Where(x => x.IsDeleted == false && x.AuthorizationStatus == 2);
                query2.AndRestrictionOn(x => x.Providerplans).IsInsensitiveLike(planid);
                List <int> output = new List <int>();
                int        count  = query2.RowCount();
                for (int i = 0; i < count; i++)
                {
                    Provider item     = query2.Skip(i).Take(1).SingleOrDefault();
                    string[] allplans = item.Providerplans.Split(',');
                    //if bound ny type is greater than -1 then check the first plan
                    if (BoundByType > -1)
                    {
                        if (allplans.Count() > 0 && allplans[0] == Convert.ToString(plantype))
                        {
                            output.Add(item.Id);
                        }
                    }
                    else
                    {
                        output.AddRange(from plan in allplans where plan.Trim() == Convert.ToString(plantype) select item.Id);
                    }
                }



                query.WhereRestrictionOn(bp => bp.Id)
                .IsIn(output);
            }

            //sort order

            //return normal list.
            totalRecord        = query.RowCount();
            totalcountinresult = totalRecord;
            IList <Provider> list = query.Skip(start).Take(lenght).List();


            if (list != null)
            {
                response.AddRange(from item in list
                                  let split       = !string.IsNullOrEmpty(item.Providerservices) ? item.Providerservices.Split(',') : new string[] { }
                                  let split2      = !string.IsNullOrEmpty(item.Providerplans) ? item.Providerplans.Split(',') : new string[] { }
                                  let servicelist = split.Select(serv => _servicevc.GetService(Convert.ToInt32(serv)).Name).ToList()
                                                    let planlist = split2.Select(plan => _plansvc.GetPlan(Convert.ToInt32(plan)).Name).ToList()
                                                                   let singleOrDefault = _userService.GetAllUsers().SingleOrDefault(x => x.Guid.ToString().ToLower() == Convert.ToString(item.CreatedBy).ToLower())

                                                                                         let providerAccount = item.Provideraccount
                                                                                                               where providerAccount != null
                                                                                                               select new ProviderVm()
                {
                    Id                     = item.Id,
                    Name                   = item.Name.ToUpper(),
                    Code                   = item.Code,
                    SubCode                = item.SubCode,
                    Phone                  = item.Phone,
                    Phone2                 = item.Phone2,
                    Email                  = item.Email,
                    Website                = item.Website,
                    Address                = item.Address,
                    Provideraccount        = providerAccount ?? new ProviderAccount(),
                    Assignee               = item.Assignee,
                    AssigneeName           = _userService.GetUser(item.Assignee).Name,
                    State                  = item.State,
                    Lganame                = item.Lga.Name,
                    Lgaid                  = item.Id,
                    AuthorizationStatus    = item.AuthorizationStatus,
                    AuthorizationNote      = item.AuthorizationNote,
                    AuthorizedBy           = item.AuthorizedBy,
                    Status                 = item.Status,
                    Providerplans          = planlist,
                    Providerservices       = servicelist,
                    CreatedBy              = singleOrDefault != null && item.CreatedBy != null ? singleOrDefault.Name : "--",
                    Zone                   = _helpersvc.GetzonebyId(Convert.ToInt32(item.State.Zone)).Name,
                    BankName               = _helpersvc.Getbank(providerAccount.BankId).Name,
                    CreatedDate            = item.CreatedOn.ToString("dd MMM yyyy"),
                    ProviderplansStr       = item.Providerplans,
                    ProviderservicesStr    = item.Providerservices,
                    AuthorizedDate         = item.AuthorizedDate,
                    AuthorizedByString     = item.AuthorizedBy > 0 ? _userService.GetUser(item.AuthorizedBy).Name : "--",
                    AuthorizationStatusStr = Enum.GetName(typeof(AuthorizationStatus), item.AuthorizationStatus),
                    CategoryString         = Enum.GetName(typeof(ProviderCategory), item.Category),
                    category               = item.Category,
                    services               = item.Servicesanddays
                });
                return(response);
            }
            return(new List <ProviderVm>());
        }
示例#20
0
 public void UpdateCategory(ProviderCategory category)
 {
     _categoryRepository.Update(category);
     _contextProvider.CommitChanges();
 }
示例#21
0
 public void SaveOrUpdate(ProviderCategory category)
 {
     _commonDao.SaveOrUpdateObject(category);
 }
示例#22
0
 public void Delete(ProviderCategory category)
 {
     _commonDao.DeleteObject(category);
 }
示例#23
0
        protected void buttonSubmit_OnClick(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["ProviderID"] != null && Convert.ToInt32(Request.QueryString["ProviderID"]) > 0)
                {
                    _provider = Module.ProviderGetByID(Convert.ToInt32(Request.QueryString["ProviderID"]));
                }
                else
                {
                    _provider           = new Provider();
                    _provider.CreatedBy = ((User)Page.User.Identity).Id;
                }
                _provider.ModifiedBy = ((User)Page.User.Identity).Id;

                _provider.Name         = textBoxName.Text;
                _provider.Address      = textBoxAddress.Text;
                _provider.Website      = textBoxWebsite.Text;
                _provider.Tel          = textBoxTel.Text;
                _provider.Mobile       = textBoxMobile.Text;
                _provider.Fax          = textBoxFax.Text;
                _provider.Description  = FCKDescription.Value;
                _provider.Map          = textBoxHiddenMap.Text;
                _provider.Image        = textBoxHiddenImage.Text;
                _provider.ProviderType = (ProviderType)ddlTypes.SelectedIndex;

                #region - Location

                if (ddlLocation.Enabled && ddlLocation.SelectedIndex > 0)
                {
                    _provider.Location = Module.LocationGetById(Convert.ToInt32(ddlLocation.SelectedValue));
                }
                else if (ddlCity.Enabled && ddlCity.SelectedIndex > 0)
                {
                    _provider.Location = Module.LocationGetById(Convert.ToInt32(ddlCity.SelectedValue));
                }
                else if (ddlRegion.Enabled && ddlRegion.SelectedIndex > 0)
                {
                    _provider.Location = Module.LocationGetById(Convert.ToInt32(ddlRegion.SelectedValue));
                }
                else if (ddlCountry.Enabled && ddlCountry.SelectedIndex > 0)
                {
                    _provider.Location = Module.LocationGetById(Convert.ToInt32(ddlCountry.SelectedValue));
                }
                else
                {
                    labelValidLocation.Visible = true;
                    return;
                }
                #endregion

                //foreach // Xử lý lưu dữ liệu
                //Đối với từng repeater
                foreach (RepeaterItem item in rptCategory.Items)
                {
                    HiddenField hiddenId    = item.FindControl("hiddenId") as HiddenField;
                    CheckBox    chkCategory = item.FindControl("chkCategory") as CheckBox;
                    if (hiddenId != null && chkCategory != null)
                    {
                        if (_hashtable[Convert.ToInt32(hiddenId.Value)] != null && !chkCategory.Checked)
                        {
                            Module.Delete(Module.Provider_CategoryGetById(Convert.ToInt32(_hashtable[Convert.ToInt32(hiddenId.Value)])));
                        }
                        if (_hashtable[Convert.ToInt32(hiddenId.Value)] == null && chkCategory.Checked)
                        {
                            ProviderCategory category = Module.ProviderCategoryGetById(Convert.ToInt32(hiddenId.Value));
                            Module.SaveProviderCategory(_provider, category);
                        }
                    }
                }

                if (_provider.Id > 0)
                {
                    Module.Update(_provider);
                    labelUpdateStatus.Visible = true;
                }
                else
                {
                    Module.Save(_provider);
                    PageRedirect(string.Format("ProviderList.aspx?NodeId={0}&SectionId={1}", Node.Id, Section.Id));
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error when buttonSubmit_OnClick in ProviderEdit", ex);
                throw;
            }
        }
示例#24
0
        public void DeleteCategory_CategoryNotFound_ThrowsException()
        {
            var providerCategory = new ProviderCategory();

            Assert.That(() => _initializer.ProviderService.DeleteCategory(providerCategory), Throws.Exception);
        }