예제 #1
0
        public void AddStudentMark(StudentMarkViewModel model)
        {
            int?   m   = model.mark;
            string res = "";

            if (m >= 50)
            {
                res = model.result = "Pass";
            }
            else if (m < 50)
            {
                res = model.result = "Fail";
            }
            else if (m == 0)
            {
                res = "";
            }
            var tb = new StudentMarks
            {
                Student_Number = model.Student_Number,
                Student_Name   = model.Student_Name,
                Subject_Code   = model.Subject_Code,
                GroupeName     = model.GroupeName,
                ClassGroupe_id = model.ClassGroupe_id,
                mark           = model.mark,
                result         = res
            };

            uow.Repository <StudentMarks>().Insert(tb);
            uow.Save();
        }
예제 #2
0
 public ActionResult Create(LearningMVC.Models.UserList userDetails)
 {
     try
     {
         var user = new User();
         if (userDetails != null)
         {
             user.UserId      = userDetails.UserId;
             user.FirstName   = userDetails.FirstName;
             user.LastName    = userDetails.LastName;
             user.Address     = userDetails.Address;
             user.PhoneNo     = userDetails.PhoneNo;
             user.EMail       = userDetails.EMail;
             user.Company     = userDetails.Company;
             user.Designation = userDetails.Designation;
         }
         unitOfWork.UserRepository.Insert(user);
         unitOfWork.Save();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
예제 #3
0
        public bool DeleteByUserId(int userId)
        {
            _unitOfWork.TokenRepository.Delete(x => x.UserId == userId);
            _unitOfWork.Save();

            var isNotDeleted = _unitOfWork.TokenRepository.GetMany(x => x.UserId == userId).Any();

            return(!isNotDeleted);
        }
예제 #4
0
 public ActionResult CreateBaoChi(tb_BaoChi model)
 {
     if (ModelState.IsValid)
     {
         unitOfWork.BaoChiRepository.Insert(model);
         unitOfWork.Save();
         return(RedirectToAction(nameof(DanhSachBaoChi)));
     }
     return(View(model));
 }
예제 #5
0
 public ActionResult CreateHocHam(tb_HocHam model)
 {
     if (ModelState.IsValid)
     {
         unitOfWork.HocHamRepository.Insert(model);
         unitOfWork.Save();
         return(RedirectToAction(nameof(DanhSachHocHam)));
     }
     return(View(model));
 }
 /// <summary>
 /// Bu Context'te yapılan tüm değişiklikleri veritabanına kaydeder.
 /// </summary>
 /// <returns></returns>
 public virtual int Save()
 {
     try
     {
         return(_unitOfWork.Save());
     }
     catch (Exception exc)
     {
         throw exc;
     }
 }
예제 #7
0
 public JsonResult CreateEmployee(Employee employee)
 {
     employee.Id = Guid.NewGuid();
     _uow.Employees.Add(employee);
     _uow.Save();
     Generator.IsReport = "Success";
     Generator.Message  = "Employee Created Successfully";
     return(new JsonResult(new
     {
         Generator.IsReport,
         Generator.Message
     }));
 }
예제 #8
0
        /// <summary>
        ///  Процесс обработки очериди запросов на вставку.
        /// </summary>
        private void ProcessingQueueInserts()
        {
            while (true)
            {
                if (_queueInserts.Count != 0)
                {
                    try
                    {
                        // Извлекаем элемент из очереди.
                        Tuple <TypeQueue, object> elementQueue;
                        _queueInserts.TryDequeue(out elementQueue);

                        // Смотрим что за операция.
                        switch (elementQueue.Item1)
                        {
                        // Смотрим что за элемент и производим операцию.
                        case TypeQueue.Insert:
                        {
                            if (elementQueue.Item2 is Map)
                            {
                                // Добавляем в таблицу Maps.
                                Map map = (Map)elementQueue.Item2;
                                _unitOfWork.Maps.Create(map);
                            }
                            else if (elementQueue.Item2 is Point)
                            {
                                // Добавляем в таблицу Maps.
                                Point point = (Point)elementQueue.Item2;
                                _unitOfWork.Points.Create(point);
                            }

                            break;
                        }

                        case TypeQueue.Save:
                        {
                            _unitOfWork.Save();
                            break;
                        }
                        }
                    }
                    catch
                    {
                        ProcessingQueueInserts();
                    }
                }

                Thread.Sleep(5);
            }
        }
예제 #9
0
        public void AppClassMark(ClassMarkViewModel model)
        {
            using (UnitOfWork.UnitOfWork uow = new UnitOfWork.UnitOfWork())
            {
                var mark = new ClassMark
                {
                    Student_No     = model.Student_No,
                    Student_name   = model.Student_name,
                    ClassGroupe_id = model.ClassGroupe_id,
                    Subject1       = model.Subject1,
                    Subject2       = model.Subject2,
                    mark           = model.mark,
                    mark12         = model.mark12,
                    mark21         = model.mark21,
                    mark23         = model.mark32,
                    mark32         = model.mark32,

                    Subject3 = model.Subject3,
                    Subject4 = model.Subject4,
                    Subject5 = model.Subject5,
                };
                uow.Repository <ClassMark>().Insert(mark);
                uow.Save();
            }
        }
예제 #10
0
        public void Logout(string userID)
        {
            try
            {
                if (userID != null)
                {
                    using (uow = new UnitOfWork.UnitOfWork())
                    {
                        // If token exists then delete existing token

                        AuthenticationToken existingToken = uow.AuthenticationTokenRepository.Get().
                                                            Where(auth => auth.FkUserID.Equals(userID))
                                                            .FirstOrDefault();

                        if (existingToken != null)
                        {
                            // Delete token
                            uow.AuthenticationTokenRepository.Delete(existingToken);
                            uow.Save();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #11
0
        public bool UpdateProductAvailabilityPrice(ProductEL productEL)
        {
            bool isProductAvailabilityUpdated = false;

            try
            {
                Product product = new Product();

                using (uow = new UnitOfWork.UnitOfWork())
                {
                    product             = uow.ProductRepository.GetById(productEL.ProductID);
                    product.IsAvailable = productEL.IsAvailable;
                    product.Price       = productEL.Price;
                    uow.ProductRepository.Update(product);
                    uow.Save();
                    isProductAvailabilityUpdated = true;
                }
            }
            catch
            {
                isProductAvailabilityUpdated = false;
            }

            return(isProductAvailabilityUpdated);
        }
예제 #12
0
        public bool AddDocument(DocumentEL document)
        {
            bool         isInserted = false;
            UserDocument newDoc     = new UserDocument();

            using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            }))
            {
                try
                {
                    if (document != null)
                    {
                        using (uow = new UnitOfWork.UnitOfWork())
                        {
                            #region Add New Document
                            newDoc.DocID      = document.DocumentID;
                            newDoc.UserID     = document.UserID;
                            newDoc.UploadPath = document.DocumentPath;
                            uow.UserDocumentRepository.Insert(newDoc);
                            uow.Save();
                            #endregion
                            transactionScope.Complete();
                            isInserted = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    transactionScope.Dispose();
                }
                return(isInserted);
            }
        }
예제 #13
0
        public DocumentMaster AddDocumentType(DocumentEL document)
        {
            DocumentMaster newDoc = new DocumentMaster();

            using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            }))
            {
                try
                {
                    if (document != null)
                    {
                        using (uow = new UnitOfWork.UnitOfWork())
                        {
                            #region Add New Document
                            newDoc.Description  = document.Description;
                            newDoc.DocumentName = document.DocumentTypeName;
                            uow.DocumentMasterRepository.Insert(newDoc);
                            uow.Save();
                            #endregion
                            transactionScope.Complete();
                        }
                    }
                }
                catch (Exception ex)
                {
                    transactionScope.Dispose();
                }
                return(newDoc);
            }
        }
예제 #14
0
        public string Update(Employee employee)
        {
            if (employee != null)
            {
                var emp = unitOfWork.EmployeeRepository.GetByID(employee.ID);
                emp.FirstName = employee.FirstName;
                emp.LastName  = employee.LastName;
                emp.UserName  = employee.UserName;

                unitOfWork.EmployeeRepository.Update(emp);
                unitOfWork.Save();

                return("Record has been Updated");
            }
            else
            {
                return("Record has Not been Updated");
            }
        }
예제 #15
0
        public void AddStream(StreamTableViewModel model)
        {
            var newstream = new StreamTable
            {
                Stream_Code = model.Stream_Code,
                Description = model.Description
            };

            uow.Repository <StreamTable>().Insert(newstream);
            uow.Save();
        }
예제 #16
0
        public void AddGroup(GradesViewModels model)
        {
            Grade gr = new Grade
            {
                Grade_id  = model.Grade_id,
                GradeName = model.GradeName
            };

            uow.Repository <Grade>().Insert(gr);
            uow.Save();
        }
예제 #17
0
        public void AddClassGroup(ClassGroupViewModels model)
        {
            ClassGroupe grp = new ClassGroupe
            {
                ClassGroupe_id = model.ClassGroupe_id,
                GroupeName     = model.GroupeName,
                Grade_id       = model.Grade_id,
            };

            uow.Repository <ClassGroupe>().Insert(grp);
            uow.Save();
        }
예제 #18
0
        public void AddSubject(SubjectsViewModel model)
        {
            var newsubject = new Subjects
            {
                Subject_Code     = model.Subject_Code,
                DescriptiveTitle = model.DescriptiveTitle,
                Stream_Code      = model.Stream_Code
            };

            uow.Repository <Subjects>().Insert(newsubject);
            uow.Save();
        }
        public bool AddOrderReceipt(ReceiptOrderEL receiptOrderEL)
        {
            bool isOrderReceiptAdded = false;

            try
            {
                RecieptOrder recieptOrder = new RecieptOrder();
                recieptOrder = MapperUtility.MapTo(receiptOrderEL, recieptOrder);
                using (uow = new UnitOfWork.UnitOfWork())
                {
                    uow.RecieptOrderRepository.Insert(recieptOrder);
                    uow.Save();
                    isOrderReceiptAdded = true;
                    int                   orderRecieptID    = recieptOrder.RecieptOrderID;
                    List <Product>        lstProduct        = uow.ProductRepository.Get().Where(x => x.RecieptID == receiptOrderEL.RecieptID).ToList();
                    List <OrderCandidate> lstOrderCandidate = new List <OrderCandidate>();
                    foreach (Product product in lstProduct)
                    {
                        OrderCandidate orderCandidate = new OrderCandidate();
                        orderCandidate.CreatedOn      = DateTime.Now.ToString();
                        orderCandidate.IsAvailable    = false;
                        orderCandidate.Price          = "0.00";
                        orderCandidate.ProductID      = product.ProductID;
                        orderCandidate.StoreID        = receiptOrderEL.ReceiverStoreID;
                        orderCandidate.UpdatedOn      = null;
                        orderCandidate.RecieptOrderID = orderRecieptID;
                        lstOrderCandidate.Add(orderCandidate);
                    }
                    uow.OrderCandidateRepository.InsertBulk(lstOrderCandidate);
                    uow.Save();
                }
            }
            catch
            {
                isOrderReceiptAdded = false;
            }

            return(isOrderReceiptAdded);
        }
예제 #20
0
 public void UpdateStatus(ViewApplicationViewModel viewmodel)
 {
     using (UnitOfWork.UnitOfWork uow = new UnitOfWork.UnitOfWork())
     {
         var application = uow.Repository <Application>().GetById(viewmodel.IdNumber);
         if (application != null)
         {
             application.Status = viewmodel.Status;
             uow.Repository <Application>().Update(application);
             uow.Save();
         }
     }
 }
예제 #21
0
 public void AssignTeacherToClass(AssignTeacherToClassViewmodel model)
 {
     using (UnitOfWork.UnitOfWork uow = new UnitOfWork.UnitOfWork())
     {
         var Ass = new AssignTeacherToClass
         {
             StaffNumber  = model.StaffNumber,
             GradeGroupId = model.GradeGroupId,
         };
         uow.Repository <AssignTeacherToClass>().Insert(Ass);
         uow.Save();
     }
 }
예제 #22
0
        public bool EditDocumentType(DocumentEL document)
        {
            bool isUpdated = false;

            try
            {
                if (document != null)
                {
                    DocumentMaster existingDoc = null;

                    using (uow = new UnitOfWork.UnitOfWork())
                    {
                        existingDoc = uow.DocumentMasterRepository.Get().Where(u => u.DocumentID.Equals(document.DocumentTypeID)).FirstOrDefault();

                        #region Get Existing User

                        if (existingDoc == null)
                        {
                            return(isUpdated);
                        }
                        // Check updating email id exists for other user

                        #endregion


                        #region Update Document

                        existingDoc.DocumentName = document.DocumentTypeName;
                        existingDoc.Description  = document.Description;

                        uow.DocumentMasterRepository.Update(existingDoc);
                        uow.Save();

                        #endregion

                        #region PrepareResponse

                        isUpdated = true;

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                isUpdated = false;
                return(isUpdated);
            }

            return(isUpdated);
        }
예제 #23
0
        //UnitOfWork.UnitOfWork uow = new UnitOfWork.UnitOfWork();
        //public void AddGroup(GradesViewModels model)
        //{
        //    Grade gr = new Grade
        //    {
        //        Grade_id = model.Grade_id,
        //        GradeName = model.GradeName
        //    };
        //    uow.Repository<Grade>().Insert(gr);
        //    uow.Save();
        //}
        //public List<GradesViewModels> GetAllGroup()
        //{
        //    return uow.Repository<Grade>().GetAll().Select(t => new GradesViewModels
        //    {
        //        Grade_id = t.Grade_id,
        //        GradeName = t.GradeName,

        //    }).ToList();


        //}

        //public GradesViewModels GetById(int id)
        //{
        //    //string t=
        //    var appview = new GradesViewModels();
        //    var app = uow.Repository<Grade>().GetById(id);


        //    appview.Grade_id = app.Grade_id;
        //    appview.GradeName = app.GradeName;
        //    return appview;

        //}
        public void AssignTeacherToSubject(AssignTeacherToSubjectViewModel model)
        {
            using (UnitOfWork.UnitOfWork uow = new UnitOfWork.UnitOfWork())
            {
                var AssT = new AssignTeacherToSubject
                {
                    StaffNumber  = model.StaffNumber,
                    GradeGroupId = model.GradeGroupId,
                    SubjectCode  = model.SubjectCode,
                };
                uow.Repository <AssignTeacherToSubject>().Insert(AssT);
                uow.Save();
            }
        }
예제 #24
0
 public void AddLoginAnalytic(LoginAnalyticsEntity loginAnalyticEntity)
 {
     using (uow = new UnitOfWork.UnitOfWork())
     {
         LoginAnalytic loginAnalytic = new LoginAnalytic();
         loginAnalytic.Date      = DateTime.Now.ToShortDateString();
         loginAnalytic.IPAddress = loginAnalyticEntity.IPAddress;
         loginAnalytic.OS        = loginAnalyticEntity.OS;
         loginAnalytic.Platform  = loginAnalyticEntity.Platform;
         loginAnalytic.Username  = loginAnalyticEntity.Username;
         loginAnalytic.Browser   = loginAnalyticEntity.Browser;
         uow.LoginAnalyticRepository.Insert(loginAnalytic);
         uow.Save();
     }
 }
예제 #25
0
        public void RegisterUser(UsersEL users)
        {
            Random randPassword = new Random();

            using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            }))
            {
                try
                {
                    if (users != null)
                    {
                        using (uow = new UnitOfWork.UnitOfWork())
                        {
                            #region Create New User
                            string RandomPassword = randPassword.Next(10000, 99999).ToString();
                            User   newUser        = new User();
                            newUser.Name     = users.Name;
                            newUser.Username = users.Username;
                            newUser.Email    = users.Email;
                            newUser.PhoneNo  = users.PhoneNo;
                            //newUser.Password = new Util().GetHashString(RandomPassword);
                            newUser.Password    = EncryptionHelper.Encrypt(RandomPassword);
                            newUser.Address     = users.Address;
                            newUser.Country     = users.Country;
                            newUser.State       = users.State;
                            newUser.Zipcode     = users.Zipcode;
                            newUser.Active      = true;
                            newUser.CreatedDate = System.DateTime.UtcNow;
                            newUser.UserRoleID  = Convert.ToInt32(users.RoleID);
                            newUser.USDot       = users.UsDot;
                            uow.UserRepository.Insert(newUser);
                            uow.Save();

                            #endregion
                            transactionScope.Complete();

                            EmailHelper emailHelper = new EmailHelper();
                            //  emailHelper.SendHtmlFormattedEmail("New account created", newUser, RandomPassword);
                        }
                    }
                }
                catch (Exception ex)
                {
                    transactionScope.Dispose();
                }
            }
        }
예제 #26
0
 public void AddDocumentAnalytic(DocumentAnalyticEntity documentAnalyticEntity)
 {
     using (uow = new UnitOfWork.UnitOfWork())
     {
         DocumentAnalytic loginAnalytic = new DocumentAnalytic();
         loginAnalytic.Date         = DateTime.Now.ToString();
         loginAnalytic.IPAddress    = documentAnalyticEntity.IPAddress;
         loginAnalytic.OS           = documentAnalyticEntity.OS;
         loginAnalytic.Platform     = documentAnalyticEntity.Platform;
         loginAnalytic.Username     = documentAnalyticEntity.Username;
         loginAnalytic.Browser      = documentAnalyticEntity.Browser;
         loginAnalytic.DocumentName = documentAnalyticEntity.DocumentName;
         uow.DocumentAnalyticRepository.Insert(loginAnalytic);
         uow.Save();
     }
 }
        public bool UpdateOrderCandidateByStoreProduct(List <OrderCandidateEL> orderCandidateELList)
        {
            bool isOrderCandidatePriceUpdated = false;

            try
            {
                List <OrderCandidate> lstOrders = new List <OrderCandidate>();
                double subtotal       = 0.00;
                int    orderRecieptID = 0;
                using (uow = new UnitOfWork.UnitOfWork())
                {
                    foreach (OrderCandidateEL orderCandidateEL in orderCandidateELList)
                    {
                        OrderCandidate orderCandidate = uow.OrderCandidateRepository.Get().Where(x => x.StoreID == orderCandidateEL.StoreID && x.ProductID == orderCandidateEL.ProductID).FirstOrDefault();
                        orderCandidate.Price       = orderCandidateEL.Price;
                        orderCandidate.IsAvailable = orderCandidateEL.IsAvailable;
                        orderCandidate.UpdatedOn   = DateTime.Now.ToString();
                        subtotal       = subtotal + Convert.ToDouble(orderCandidateEL.Price);
                        orderRecieptID = Convert.ToInt32(orderCandidate.RecieptOrderID);
                        lstOrders.Add(orderCandidate);
                    }
                    uow.OrderCandidateRepository.UpdateBulk(lstOrders);
                    isOrderCandidatePriceUpdated = true;
                }
                using (uow = new UnitOfWork.UnitOfWork())
                {
                    RecieptOrder recOrder = uow.RecieptOrderRepository.Get().Where(x => x.RecieptOrderID == orderRecieptID).FirstOrDefault();
                    if (recOrder != null)
                    {
                        recOrder.Subtotal = subtotal.ToString();
                        uow.RecieptOrderRepository.Update(recOrder);
                        uow.Save();
                        RecieptEL recEL = new RecieptEL();

                        recEL.Status    = ((int)ReceiptStatus.Quoted).ToString();
                        recEL.RecieptID = Convert.ToInt32(recOrder.RecieptID);

                        recHelper.UpdateOrderReceipt(recEL);
                    }
                }
            }
            catch
            {
            }
            return(isOrderCandidatePriceUpdated);
        }
예제 #28
0
        public string UpdateRole(Employee permission)
        {
            if (permission != null)
            {
                var emp = unitOfWork.EmployeeRepository.GetByID(permission.ID);
                emp.RoleID = permission.RoleID;

                unitOfWork.EmployeeRepository.Update(emp);
                unitOfWork.Save();

                return("Record has been Updated");
            }
            else
            {
                return("Record has Not been Updated");
            }
        }
예제 #29
0
        public bool DeleteDocumentType(string id)
        {
            bool isDeleted = false;

            try
            {
                using (uow = new UnitOfWork.UnitOfWork())
                {
                    DocumentMaster doc = uow.DocumentMasterRepository.Get().Where(x => x.DocumentID == Convert.ToInt32(id)).FirstOrDefault();
                    uow.DocumentMasterRepository.Delete(doc);
                    uow.Save();
                }
            }
            catch (Exception ex)
            {
            }
            return(isDeleted);
        }
        public bool AddOrderCandidate(OrderCandidateEL orderCandidateEL)
        {
            bool isOrderCandidateAdded = false;

            try
            {
                OrderCandidate orderCandidate = new OrderCandidate();
                orderCandidate = MapperUtility.MapTo(orderCandidateEL, orderCandidate);
                using (uow = new UnitOfWork.UnitOfWork())
                {
                    uow.OrderCandidateRepository.Insert(orderCandidate);
                    uow.Save();
                    isOrderCandidateAdded = true;
                }
            }
            catch
            {
            }
            return(isOrderCandidateAdded);
        }