Beispiel #1
0
 public SecondForm()
 {
     InitializeComponent();
     _querySession = new CustomRepository();
     _session      = new ClientRepository();
     GetListOfClient();
 }
Beispiel #2
0
        public ActionResult LoginUser(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                tblUser logedInUser = _dbRepository.GetEntities().FirstOrDefault(m => m.Username == model.UserName && m.Password == model.Password);

                if (logedInUser == null)
                {
                    TempData[Enums.NotifyType.Error.GetDescription()] = "Invalid Login Credentials.";
                    return(View("Index", model));
                }
                else
                {
                    SessionHelper.UserId                = Convert.ToInt32(logedInUser.UserId);
                    SessionHelper.WelcomeUser           = logedInUser.Name;
                    SessionHelper.RoleId                = logedInUser.RoleId == null ? 0 : (int)logedInUser.RoleId;
                    SessionHelper.Email                 = logedInUser.UserEmail;
                    SessionHelper.UserAccessPermissions = CustomRepository.UserAccessPermissions(SessionHelper.RoleId, logedInUser.IsSuperAdmin);
                    CommonHelper.UserId                 = Convert.ToInt32(logedInUser.UserId);
                    FormsService.SignIn(logedInUser.Name, model.RememberMe);

                    TempData[Enums.NotifyType.Success.GetDescription()] = "Login Successfully.";
                    return(RedirectToAction("Index", "Home"));
                }
            }

            return(View("Index", model));
        }
Beispiel #3
0
 public CustomTest()
 {
     // Arrange
     _mockRepo = new Mock <ICustom>();
     repo      = new CustomRepository();
     //_mockRepo.Setup(repo => repo.Custom()).Returns(200);
 }
        public void FinByGlossary_test(int id, string criteria)
        {
            CustomRepository <string> repo = new CustomRepository <string>();
            DataSet ds = (DataSet)repo.FindByGlossary(id, criteria);

            Assert.IsTrue(ds.Tables["Customer"].Rows.Count > 0);
        }
Beispiel #5
0
        //[Route("/[controller]/SignUpPost")]

        public async Task <IActionResult> SignUp(RegisterViewModel model)
        {
            ViewBag.Error = "";
            if (ModelState.IsValid)
            {
                Regex regex = new Regex(@"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");
                Match match = regex.Match(model.Email.Trim().ToLower());
                if (!match.Success)
                {
                    return(new JsonResult(new { code = 0, Err = "" }));
                }

                var result = CustomRepository.CreateUser(model.Email, model.PhoneNumber, model.Password, model.FullName, model.ProvinceId, model.DistricId, model.WardId, model.PlaceDetail);
                if (result != null)
                {
                    EmailHelper.SendConfirmEmail(result);
                    var user = _db.TblUsers.Where(x => x.Email.Equals(model.Email)).FirstOrDefault();
                    var re   = await CustomRepository.AddUserToRoleAsync(user, 3);

                    if (re == true)
                    {
                        return(RedirectToAction("SignIn", "Account", new { Email = user.Email }));
                    }
                }
                else
                {
                    ViewBag.Error = "Người dùng đã tồn tại";
                    return(RedirectToAction(nameof(SignUp)));
                }
            }
            return(new JsonResult(new { code = 0, Err = "*Có lỗi xảy ra, vui lòng thử lại" }));
        }
        public long Insert(InvoiceModel model)
        {
            TblInvoice obj = _mapper.Map <InvoiceModel, TblInvoice>(model);

            obj.Day         = model.InvoiceDate.Day;
            obj.Month       = model.InvoiceDate.Month;
            obj.Year        = model.InvoiceDate.Year;
            obj.InvoiceNo   = "";
            obj.SequenceNo  = 0;
            obj.TotalAmount = CustomRepository.GetTotalAmountForInvoice(model.checkedDispatchId).TotalAmount;

            decimal SgstAmount = Math.Round(obj.TotalAmount * (model.Sgst ?? 0) / 100, 2);
            decimal IgstAmount = Math.Round(obj.TotalAmount * (model.Igst ?? 0) / 100, 2);
            decimal CgstAmount = Math.Round(obj.TotalAmount * (model.Cgst ?? 0) / 100, 2);

            obj.TaxAmount          = SgstAmount + IgstAmount + CgstAmount;
            obj.TotalAmountWithTax = obj.TotalAmount + obj.TaxAmount;
            obj.AmountInWords      = CurrencyHelper.changeCurrencyToWords(obj.TotalAmountWithTax);

            List <long> dispatchIdList = model.checkedDispatchId.Split(',').Select(long.Parse).ToList();

            foreach (long dispatchId in dispatchIdList)
            {
                obj.TblInvoiceDetail.Add(new TblInvoiceDetail
                {
                    DispatchId = dispatchId
                });
            }

            _repository.Insert(obj);
            return(obj.InvoiceId);
        }
        public void FinById_test(int id)
        {
            CustomRepository <string> repo = new CustomRepository <string>();
            DataSet ds = (DataSet)repo.FindByID(id);

            Assert.IsTrue(ds.Tables["Customer"].Rows.Count > 0);
        }
        public ActionResult SaveInquiry(tblInquiry model)
        {
            if (ModelState.IsValid)
            {
                using (StudioCraftEntities context = CustomRepository.GetDbContext())
                {
                    context.tblInquiry.Add(model);
                    context.SaveChanges();
                }

                string bodyTemplate = System.IO.File.ReadAllText(Server.MapPath("~/Template/InquiryTemplate.html"));

                bodyTemplate = bodyTemplate.Replace("[@NAME]", model.Name);
                bodyTemplate = bodyTemplate.Replace("[@EMAIL]", model.Email);
                bodyTemplate = bodyTemplate.Replace("[@BUDGET]", model.Budget);
                bodyTemplate = bodyTemplate.Replace("[@MESSAGE]", model.Message);
                bodyTemplate = bodyTemplate.Replace("[@REGARDING]", model.Regarding);

                Task task = new Task(() => EmailHelper.SendMail("Studio Craft - New Inquiry", bodyTemplate, true));
                task.Start();

                return(RedirectToAction("ThankYou"));
            }
            return(View("Index"));
        }
Beispiel #9
0
        public ActionResult KendoRead([DataSourceRequest] DataSourceRequest request, int PreCommissionId)
        {
            if (!request.Sorts.Any())
            {
                request.Sorts.Add(new SortDescriptor("PreCommisoningDate", ListSortDirection.Descending));
            }

            DataSourceResult result = CustomRepository.GetPreCommisioningDetailData(PreCommissionId).ToDataSourceResult(request);
            //DataSourceResult result = _dbRepository.GetEntities().Where(m => m.PreCommissionId == PreCommissionId).ToDataSourceResult(request);
            List <GetPreCommisioningDetailData_Result> list = result.Data as List <GetPreCommisioningDetailData_Result>;

            foreach (GetPreCommisioningDetailData_Result obj in list)
            {
                if (obj.PCAccesseriesId > 0)
                {
                    obj.PCAccessoryIdList = new List <int>();
                    obj.PCAccessoryIdList.Add(obj.PCAccesseriesId.Value);
                }
                if (obj.PCMachineId > 0)
                {
                    obj.PCMachineIdList = new List <int>();
                    obj.PCMachineIdList.Add(obj.PCMachineId.Value);
                }
            }
            return(Json(list.ToDataSourceResult(request)));
        }
Beispiel #10
0
        public ActionResult Index(LoginModel model)
        {
            //if (!ModelState.IsValid)
            //{
            //    return View("Index", model);
            //}
            var UserNameParam = new SqlParameter
            {
                ParameterName = "UserName",
                DbType        = DbType.String,
                Value         = model.UserName
            };
            var PasswordParam = new SqlParameter
            {
                ParameterName = "Password",
                DbType        = DbType.String,
                Value         = model.Password
            };

            UserModel logedInUser = new UserModel();

            using (AgroAppEntities obj = new AgroAppEntities())
            {
                try
                {
                    var List = obj.Database.SqlQuery <UserModel>("Sp_UserLogin @UserName,@Password", UserNameParam, PasswordParam).FirstOrDefault();
                    logedInUser = List;
                }
                catch (Exception ex)
                {
                    return(View());
                }
            }


            if (logedInUser == null)
            {
                ModelState.AddModelError("UserName", "Invalid Login Credentials.");
                return(View(model));
            }

            if (!logedInUser.IsActive)
            {
                ModelState.AddModelError("UserName", string.Format("User '{0}' is no longer active.", logedInUser.UserName));
                return(View(model));
            }

            SessionHelper.UserId                = Convert.ToInt32(logedInUser.UserId);
            SessionHelper.WelcomeUser           = logedInUser.Name;
            SessionHelper.RoleId                = logedInUser.RoleId;
            SessionHelper.Email                 = logedInUser.EmailAddress;
            SessionHelper.Password              = logedInUser.Password;
            SessionHelper.IsSuperAdmin          = logedInUser.IsSuperAdmin;
            SessionHelper.ProfilePic            = logedInUser.Image;
            SessionHelper.UserAccessPermissions = CustomRepository.UserAccessPermissions(SessionHelper.RoleId, logedInUser.IsSuperAdmin);
            FormsService.SignIn(logedInUser.UserName, model.RememberMe);

            return(RedirectToAction("Index", "Home"));
        }
        public string Get([FromServices] CustomRepository repo, [FromQuery] string key)
        {
            Console.WriteLine(repo.Get(key));
            repo.Text = "Invalid value";
            Console.WriteLine(repo.Text);

            return("Get OK");
        }
        async public Task <string> GetAsync([FromServices] CustomRepository repo, [FromQuery] string key)
        {
            Console.WriteLine(await repo.GetAsync(key));
            repo.Text = "Invalid value";
            Console.WriteLine(repo.Text);

            return("GetAsync OK");
        }
        public void Validation_Test()
        {
            CustomRepository <string> repo = new CustomRepository <string>();
            DataSet ds = (DataSet)repo.FillAll();

            repo.Validation();
            Assert.IsTrue(ds.Tables["Error"].Rows.Count > 0);
        }
Beispiel #14
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (CustomRepository.CheckProductExistsINOrder(OrderId, ProductId, OrderDetailId))
     {
         var fieldName = new[] { "ProductId" };
         yield return(new ValidationResult("Product Already Exists.", fieldName));
     }
 }
Beispiel #15
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (CustomRepository.CheckCoreAlreadyExists(Name, Thickness, CoreId))
     {
         var fieldName = new[] { "Name" };
         yield return(new ValidationResult("Core with same Name & Thickness already Exists.", fieldName));
     }
 }
Beispiel #16
0
        public object FillAllCustomers()
        {
            _lastQuery = QueryCriteria.GetAll;
            _paramsObjects.Clear();
            var _repo = new CustomRepository <string>();

            return(_repo.FillAll());
        }
Beispiel #17
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (CustomRepository.CheckRoleExistsOrNot(RoleName, RoleId))
     {
         var fieldName = new[] { "RoleName" };
         yield return(new ValidationResult("Role is Already Exists.", fieldName));
     }
 }
 /// <summary>
 /// Method to bind the dispatch grid
 /// </summary>
 /// <param name="request">DataSource Request</param>
 /// <param name="customerId">Customer Id</param>
 /// <param name="consigneeId">Consignee Id</param>
 /// <param name="invoiceId">Invoice Id</param>
 /// <param name="isFinalize">Is finalized</param>
 /// <returns></returns>
 public IActionResult KendoReadDispatch([DataSourceRequest] DataSourceRequest request, long?customerId = null, long?consigneeId = null, long?invoiceId = null, bool?isFinalize = false)
 {
     if (!request.Sorts.Any())
     {
         request.Sorts.Add(new SortDescriptor("DispatchDate", ListSortDirection.Ascending));
     }
     return(Json(CustomRepository.GetInvoiceDispatchList(customerId, consigneeId, invoiceId, isFinalize).ToDataSourceResult(request)));
 }
Beispiel #19
0
 public IActionResult KendoReadOrder4Dispatch([DataSourceRequest] DataSourceRequest request, long buyerId, long consigneeId, long productId)
 {
     if (!request.Sorts.Any())
     {
         request.Sorts.Add(new SortDescriptor("OrderNo", ListSortDirection.Ascending));
     }
     return(Json(CustomRepository.GetDispatchOrderList(buyerId, consigneeId, productId).ToDataSourceResult(request)));
 }
Beispiel #20
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (CustomRepository.CheckProductExistsOrNot(FilmType, (decimal)Thickness, ProductId))
     {
         var fieldName = new[] { "FilmType" };
         yield return(new ValidationResult("Product With Same micron Already Exists.", fieldName));
     }
 }
Beispiel #21
0
 public IActionResult KendoReadSlitting([DataSourceRequest] DataSourceRequest request, long?dispatchId = null, long?buyerId = null, long?consigneeId = null, bool?isFinalize = false)
 {
     if (!request.Sorts.Any())
     {
         request.Sorts.Add(new SortDescriptor("SlittingRollNo", ListSortDirection.Ascending));
     }
     return(Json(CustomRepository.GetDispatchSlittingList(buyerId, consigneeId, dispatchId, isFinalize).ToDataSourceResult(request)));
 }
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (CustomRepository.CheckConsigneeExistsOrNot(Gstnumber, PanNumber, PhoneNumber, ConsigneeId))
     {
         var fieldName = new[] { "Name" };
         yield return(new ValidationResult("Consignee is Already Exists.", fieldName));
     }
 }
 /// <summary>
 /// Method to bind the slitting grid
 /// </summary>
 /// <param name="request">DataSource Request</param>
 /// <param name="dispatchId">DispatchId</param>
 /// <returns></returns>
 public IActionResult KendoReadSlittingByDispatchId([DataSourceRequest] DataSourceRequest request, long?dispatchId = null)
 {
     if (!request.Sorts.Any())
     {
         request.Sorts.Add(new SortDescriptor("SlittingRollNo", ListSortDirection.Ascending));
     }
     return(Json(CustomRepository.GetInvoiceSlittingList(dispatchId).ToDataSourceResult(request)));
 }
Beispiel #24
0
 public ActionResult KendoReadWarrantyExpiry([DataSourceRequest] DataSourceRequest request)
 {
     if (!request.Sorts.Any())
     {
         request.Sorts.Add(new SortDescriptor("CustomerName", ListSortDirection.Ascending));
     }
     return(Json(CustomRepository.GetWarrantyExpiryCustomerList().ToDataSourceResult(request)));
 }
 public IActionResult KendoReadJumboRollStock([DataSourceRequest] DataSourceRequest request)
 {
     if (!request.Sorts.Any())
     {
         request.Sorts.Add(new SortDescriptor("JumboNo", ListSortDirection.Ascending));
     }
     return(Json(CustomRepository.GetJumboRollStockList().ToDataSourceResult(request)));
 }
Beispiel #26
0
        public object GetCustomersByBirthday(DateTime date)
        {
            _lastQuery = QueryCriteria.Bithday;
            _paramsObjects.Clear();
            _paramsObjects.Add(date);
            CustomRepository <DateTime> _repo = new CustomRepository <DateTime>();

            return(_repo.FindBy(QueryCriteria.Bithday, date));
        }
 public IActionResult GetUserRightsList(DataSourceRequest request, int RoleId)
 {
     if (RoleId != 0)
     {
         List <UserRightsModel> list = CustomRepository.GetUserRightsList(RoleId).ToList();
         return(Json(list.ToDataSourceResult(request)));
     }
     return(Json(new List <UserRightsModel>().ToDataSourceResult(request)));
 }
Beispiel #28
0
        public object GetCustomersByLastName(string lastName)
        {
            _lastQuery = QueryCriteria.LastName;
            _paramsObjects.Clear();
            _paramsObjects.Add(lastName);
            CustomRepository <string> _repo = new CustomRepository <string>();

            return(_repo.FindBy(QueryCriteria.LastName, lastName));
        }
        public ActionResult KendoReadDetailById([DataSourceRequest] DataSourceRequest request, int preCommisioningId)
        {
            //if (!request.Sorts.Any())
            //{
            //    request.Sorts.Add(new SortDescriptor("PreCommissioningId", ListSortDirection.Ascending));
            //}

            return(Json(CustomRepository.GetPreCommisioningListDetail(preCommisioningId).ToDataSourceResult(request)));
        }
Beispiel #30
0
        public ActionResult KendoRead([DataSourceRequest] DataSourceRequest request)
        {
            //if (!request.Sorts.Any())
            //{
            //    request.Sorts.Add(new SortDescriptor("MachinePartsQuotationId", ListSortDirection.Ascending));
            //}

            return(Json(CustomRepository.GetPartsQuoatationList().ToDataSourceResult(request)));
        }