Esempio n. 1
0
        public ActionResult Create(Discount discount)
        {
            _fR.Add(discount);
            _fR.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public override void OnException(ExceptionContext filterContext)
        {
            if (filterContext.ExceptionHandled || filterContext.HttpContext.IsCustomErrorEnabled)
            {
                return;
            }
            //
            //add mvc error to DB
            _fR.Add(new ErrorLog
            {
                Action           = filterContext.RouteData.Values["action"].ToString(),
                Controller       = filterContext.RouteData.Values["controller"].ToString(),
                ExceptionMessage = filterContext?.Exception?.Message ?? "",
                StackTrace       = filterContext.Exception?.StackTrace ?? "",
                Date             = filterContext.RequestContext.HttpContext.Timestamp.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                RequestUrl       = filterContext.HttpContext.Request.Url.ToString(),
                Browser          = $"{filterContext.HttpContext.Request.Browser.Browser.ToString()} - Version:{filterContext.HttpContext.Request.Browser.Version.ToString()}"
            });

            filterContext.ExceptionHandled = true;
            filterContext.Result           = new ViewResult()
            {
                ViewName = "Error"
            };
        }
Esempio n. 3
0
        public ActionResult Create(Product product)
        {
            product.CreatedDate = DateTime.Now;
            product.Status      = true;
            _fR.Add(product);
            _fR.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        public ActionResult Create(Supplier supplier)
        {
            supplier.CreatedDate = DateTime.Now;
            supplier.Status      = true;
            _fR.Add(supplier);
            _fR.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
        public ActionResult Create(Company company)
        {
            company.CreatedDate = DateTime.Now;
            company.Status      = true;
            _fR.Add(company);
            _fR.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 6
0
        public ActionResult Login(LoginModel model)
        {
            //sing out all froms auth
            FormsAuthentication.SignOut();
            //
            //check out if values null
            if (model.Username.IsNull() || model.Password.IsNull())
            {
                //return error message
                ModelState.AddModelError("ErrorMessage", "Kullanıcı adı veya parola boş bırakılamaz Lütfen doldurunuz");
                return(View("Login", model));
            }

            if (model.Username?.Trim().ToLower() != "Username".GetAppSetting().ToLower() || model.Password?.Trim() != "Password".GetAppSetting())
            {
                //return error message
                ModelState.AddModelError("ErrorMessage", "Kullanıcı adı veya parola yanlış. Lütfen kontol edip tekrar deneyin");
                return(View("Login", model));
            }
            //
            //save login data on cookie
            CookieHelper.SetCookiesValue(model);
            //
            _fR.DeleteLoginLogMoreThanThreeMonths();
            //
            string hostName, userHostAddress;

            try
            {
                userHostAddress = Helper.RequestHelpers.GetClientIpAddress(Request);
                //
                //get ip address
#pragma warning disable CS0618 // Type or member is obsolete
                hostName = System.Net.Dns.GetHostByName(hostName: Environment.MachineName)?.AddressList[0]?.ToString() ?? "";
#pragma warning restore CS0618 // Type or member is obsolete
            }
            catch (Exception ex)
            {
                hostName        = ex?.InnerException?.Message ?? ex.Message;
                userHostAddress = "";
            }
            //
            //
            _fR.Add(new AccountLog
            {
                HostName          = $"{Environment.MachineName} - {hostName}",
                UserHostAddress   = userHostAddress,
                LogonUserIdentity = Request?.LogonUserIdentity?.Name ?? "",
                LoggedTime        = DateTime.Now,
            });
            _fR.SaveChanges();
            //return main page
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 7
0
        public ActionResult Save(SaveVoucherJsonModel model)
        {
            var alreadyUsedVoucherNo = _fR.GetAny <Order>(x => x.VoucherNumber == model.VoucherNo && x.Status && !x.IsDeleted);

            if (alreadyUsedVoucherNo)
            {
                return(Json(new Response {
                    Status = false, Message = "Belge no daha önce kullanılmış"
                }, JsonRequestBehavior.AllowGet));
            }

            using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
            {
                try
                {
                    //
                    //order date parse useable datetime format
                    DateTime voucherDate;
                    try
                    {
                        voucherDate = DateTime.ParseExact(model.VoucherDate, "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture);
                    }
                    catch (Exception ex)
                    {
                        return(Json(new Response {
                            Status = false, Message = "Tarih formatı yanlış Lütfen sayfayı yenileyip tekrar deneyin"
                        }, JsonRequestBehavior.AllowGet));
                    }
                    //
                    var order = new Order
                    {
                        PlatformCode  = model.PlatformCode,
                        CompanyId     = model.CustomerId,
                        SupplierId    = model.SupplierId,
                        VoucherNumber = model.VoucherNo,
                        VoucherDate   = voucherDate,
                        CreatedDate   = DateTime.Now,
                        Tax           = model.TaxPercent,
                        Status        = true
                    };
                    //
                    //save order
                    _fR.Add(order);
                    _fR.SaveChanges();

                    var productList = new List <OrderProduct>();
                    foreach (var item in model.Products)
                    {
                        var op = new OrderProduct
                        {
                            OrderId        = order.Id,
                            ProductId      = item.ProductId,
                            ProductBarcode = item.Barcode,
                            ProductName    = item.ProductName,
                            Discount       = item.ProductDiscount,
                            DiscountName   = item.ProductDiscountName,
                            Quantity       = item.ProductQuantity,
                            Price          = string.IsNullOrEmpty(item.ProductPrice) ? 0 : Convert.ToDecimal(item.ProductPrice),
                        };
                        //
                        op.Total = op.CalculateTotalPrice();
                        var taxAmount = op.Total * order.Tax / 100;
                        op.Total = op.Total + taxAmount;
                        //
                        productList.Add(op);
                    }
                    //
                    //save order
                    _fR.AddList(productList);
                    _fR.SaveChanges();
                    //
                    scope.Complete();
                    return(Json(new Response {
                        Status = true, EntityId = model.VoucherNo + 1, Message = "Belge kayıt edildi."
                    }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    scope.Dispose();
                    return(Json(new Response {
                        Status = false, EntityId = 0, Message = ex.InnerException?.InnerException.Message ?? ex.Message, TotalCount = 0
                    }));
                }
            }
        }