Ejemplo n.º 1
0
        public object Post(Vendor model)
        {
            object json;

            try
            {
                model = repository.Add(model);

                json = new
                {
                    total   = 1,
                    data    = model,
                    success = true
                };
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);

                object error = new { message = ex.Message };

                json = new
                {
                    message = ex.Message,
                    success = false
                };
            };

            return(json);
        }
Ejemplo n.º 2
0
        private int CreateVendor(User usr)
        {
            Vendor vendor = new Vendor();

            vendor.VendorCreatedByUserKey = 1;
            vendor.VendorEmail            = usr.UserEmail;
            vendor.VendorName             = usr.UserName;
            vendor.VendorCreatedDate      = DateTime.Now;
            vendor = vendorRepository.Add(vendor);
            return(vendor.VendorKey);
        }
Ejemplo n.º 3
0
        public object Post(Models.Vendor added)
        {
            object json;
            string messageError = "";

            try
            {
                Models.Vendor posted = repository.Add(added, ref messageError);

                if (posted != null)
                {
                    json = new
                    {
                        total   = 1,
                        data    = posted,
                        success = true
                    };
                }
                else
                {
                    json = new
                    {
                        message = messageError,
                        success = false
                    };
                };
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);

                object error = new { message = ex.Message };

                json = new
                {
                    message = ex.Message,
                    success = false
                };
            };

            return(json);
        }