예제 #1
0
        private void btnAddRole_Click(object sender, EventArgs e)
        {
            var role = new CatalogRole
            {
                RoleName    = ddlRoles.SelectedValue,
                ReferenceId = new Guid(TypeId),
                RoleType    = CatalogRoleType.ProductTypeRole
            };

            HccApp.CatalogServices.CatalogRoles.Create(role);
            LoadRoles();
        }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(ddlRoles.SelectedValue))
     {
         var role = new CatalogRole
         {
             RoleName    = ddlRoles.SelectedValue,
             ReferenceId = new Guid(CategoryId),
             RoleType    = CatalogRoleType.CategoryRole
         };
         HccApp.CatalogServices.CatalogRoles.Create(role);
     }
     LoadRoles();
 }
예제 #3
0
        /// <summary>
        /// Adds the role.
        /// </summary>
        //[TestMethod]
        public void AddProductRole()
        {
            //Arrange
            var rolename = _irepoproductrole.GetAddProductRole();
            var prj      = GetRootProduct();
            var role     = new CatalogRole
            {
                RoleName    = rolename,
                ReferenceId = new Guid(prj.Bvin),
                RoleType    = CatalogRoleType.ProductRole
            };


            //Act/Assert
            Assert.IsTrue(_application.CatalogServices.CatalogRoles.Create(role));
        }
예제 #4
0
        public void CatalogRoles_CanAddRole()
        {
            var c = new HccRequestContext();

            c.CurrentStore.Id = 2;
            var target = new CatalogRolesRepository(c);

            var expected = new CatalogRole
            {
                RoleName    = "NewRole",
                RoleType    = CatalogRoleType.ProductRole,
                ReferenceId = new Guid("9113e66b-43fb-4eec-b9d1-84cb9750bccc")
            };

            var res    = target.Create(expected);
            var actual = target.FindAllPaged(1, 1).First();

            Assert.AreEqual(1, target.CountOfAll());
            Assert.AreEqual(expected.RoleName, actual.RoleName);
            Assert.AreEqual(expected.ReferenceId, actual.ReferenceId);
            Assert.AreEqual(expected.RoleType, actual.RoleType);
        }
예제 #5
0
        /// <summary>
        ///     Allows the REST API to create a catalog role. There is no update.
        /// </summary>
        /// <param name="parameters">Parameters passed in the URL of the REST API call. None are expected.</param>
        /// <param name="querystring">Name/value pairs from the REST API call querystring. This is not used in this method.</param>
        /// <param name="postdata">Serialized (JSON) version of the CatalogRoleDTO object</param>
        /// <returns>CatalogRoleDTO - Serialized (JSON) version of the catalog role</returns>
        public override string PostAction(string parameters, NameValueCollection querystring, string postdata)
        {
            var errors = new List <ApiError>();
            var data   = string.Empty;

            CatalogRoleDTO postedRole = null;

            try
            {
                postedRole = Json.ObjectFromJson <CatalogRoleDTO>(postdata);
            }
            catch (Exception ex)
            {
                return(JsonApiResponseException(ex));
            }

            var cRole = new CatalogRole();

            cRole.FromDto(postedRole);

            HccApp.CatalogServices.CatalogRoles.Create(cRole);

            return(JsonApiResponse(cRole.ToDto()));
        }