Exemplo n.º 1
0
        public ActionResult CreateSupplier(Supplier aObj)
        {
            string currentUserId = User.Identity.GetUserId();

            if (currentUserId != null)
            {
                var data = _aManager.CreateSupplier(aObj, currentUserId);
                return(Json(new { success = data.Status, data }, JsonRequestBehavior.AllowGet));
                //  return null;
            }
            return(RedirectToAction("Login", "Identity", new { area = "" }));
            // return RedirectToAction(/Identity/Login);
        }
        /// <summary>
        /// James Heim
        /// Created: 2019/01/24
        ///
        /// Decide what to do when the Primary button is clicked based
        /// on the current context.
        /// </summary>
        ///
        /// <remarks>
        /// James Heim
        /// Updated: 2019/01/24
        /// Added logic for Create.
        ///
        /// James Heim
        /// Updated 2019/01/30
        /// Added logic for View and Edit views.
        ///
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnPrimary_Click(object sender, RoutedEventArgs e)
        {
            if (_context.Equals(Context.Create))
            {
                // Add Button
                try
                {
                    CreateSupplier();
                    _supplierManager.CreateSupplier(_newSupplier);
                    this.DialogResult = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n" + ex.InnerException);
                }
            }
            else if (_context.Equals(Context.View))
            {
                // Edit button
                // Enable Edit mode.
                enableEditing();
                _context           = Context.Edit;
                btnPrimary.Content = "Save";
            }
            else if (_context.Equals(Context.Edit))
            {
                // Save Button
                try
                {
                    CreateSupplier();
                    _supplierManager.UpdateSupplier(_newSupplier, _oldSupplier);
                    this.DialogResult = true;
                } catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n" + ex.InnerException);
                }

                return;
            }
        }