Example #1
0
        public JsonResult AddBlacklists(string list)
        {
            var checkInsertDetail = "";

            if (list != "" && list != null)
            {
                System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "\\TempCSV.csv", list, System.Text.Encoding.UTF8);
                List <CSVModel> values = System.IO.File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + "\\TempCSV.csv")
                                         .Skip(1)
                                         .Select(v => FromCsv(v))
                                         .ToList();
                foreach (var item in values)
                {
                    tbl_BlackList visitor = new tbl_BlackList();
                    visitor.VisitorName = item.VisitorName;
                    visitor.NationalId  = item.CompanyName;
                    visitor.CompanyName = item.NationalId;
                    visitor.Reason      = item.Remark;
                    visitor.CreateBy    = mEmployee.employee.employee_id;
                    visitor.CreateDate  = DateTime.Now;
                    if (!new UserDao().InsertOrUpdateBlackList(visitor))
                    {
                        checkInsertDetail = checkInsertDetail + "Visitor: " + item.VisitorName + " with national Id: " + item.CompanyName + "; ";
                    }
                }
            }
            if (checkInsertDetail == "")
            {
                return(Json(new { status = true }));
            }
            else
            {
                return(Json(new { status = checkInsertDetail }));
            }
        }
Example #2
0
 public bool InsertOrUpdateBlackList(tbl_BlackList blackList)
 {
     try
     {
         var result = db.tbl_BlackList.FirstOrDefault(x => x.NationalId == blackList.NationalId);
         if (result != null)
         {
             result.VisitorName = blackList.VisitorName;
             result.CompanyName = blackList.CompanyName;
             result.Reason      = blackList.Reason;
             result.CreateBy    = blackList.CreateBy;
             result.CreateDate  = blackList.CreateDate;
         }
         else
         {
             db.tbl_BlackList.Add(blackList);
         }
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         WriteLogError.Write("InsertOrUpdateBlackList", ex.ToString());
         return(false);
     }
 }
Example #3
0
        public JsonResult BlackListInsertOrUpdate(string visitor, string company, string nationalId, string reason)
        {
            // check and delete permisstion
            tbl_BlackList newBlackList = new tbl_BlackList();

            newBlackList.VisitorName = visitor;
            newBlackList.CompanyName = company;
            newBlackList.NationalId  = nationalId;
            newBlackList.Reason      = reason;
            newBlackList.CreateBy    = mEmployee.employee.employee_id;
            newBlackList.CreateDate  = DateTime.Now;
            var resultUpdate = new UserDao().InsertOrUpdateBlackList(newBlackList);

            if (resultUpdate)
            {
                return(Json(new { status = true }));
            }
            else
            {
                return(Json(new { status = false }));
            }
        }