public void Save(int id)
 {
     try
     {
         var compositeRole = _role.GetDetailCompositeRole(id);
         compositeRole.Id = 0;
         var response = _role.Save(compositeRole);
         Console.WriteLine(response);
     }
     catch (Exception ex)
     {
         Assert.True(false, ex.Message);
     }
 }
        protected override void Simpan()
        {
            if (_isNewData)
            {
                _role = new Role();
            }

            _role.nama_role = txtNamaRole.Text;
            _role.is_active = rdoAktif.Checked;

            var result          = 0;
            var validationError = new ValidationError();

            if (_isNewData)
            {
                result = _bll.Save(_role, ref validationError);
            }
            else
            {
                result = _bll.Update(_role, ref validationError);
            }

            if (result > 0)
            {
                Listener.Ok(this, _isNewData, _role);

                if (_isNewData)
                {
                    base.ResetForm(this);
                    txtNamaRole.Focus();
                }
                else
                {
                    this.Close();
                }
            }
            else
            {
                if (validationError.Message != null && validationError.Message.Length > 0)
                {
                    MsgHelper.MsgWarning(validationError.Message);
                    base.SetFocusObject(validationError.PropertyName, this);
                }
                else
                {
                    MsgHelper.MsgUpdateError();
                }
            }
        }
Beispiel #3
0
        public void SaveTest()
        {
            var obj = new Role
            {
                nama_role = "Supervisor",
                is_active = true
            };

            var validationError = new ValidationError();

            var result = _bll.Save(obj, ref validationError);

            Console.WriteLine("Error : " + validationError.Message);

            Assert.IsTrue(result != 0);

            var newObj = _bll.GetByID(obj.role_id);

            Assert.IsNotNull(newObj);
            Assert.AreEqual(obj.role_id, newObj.role_id);
            Assert.AreEqual(obj.nama_role, newObj.nama_role);
            Assert.AreEqual(obj.is_active, newObj.is_active);
        }
Beispiel #4
0
 public IActionResult Save([FromBody] RoleViewModel model)
 {
     return(Ok(_role.Save(model)));
 }
 public IActionResult Save(RoleViewModel formData)
 {
     return(Ok(_role.Save(formData)));
 }