示例#1
0
        public CommonResponse GetDeliveryMaterial()
        {
            var response          = new CommonResponse();
            var ctx               = context as MROContext;
            var inventoryDelivery = ctx.InventoryInputs.AsQueryable();
            var filter            = HttpContext.Current.Request["CatMaterialKey"];

            if (!string.IsNullOrWhiteSpace(filter) && filter != null && filter != "undefine")
            {
                var catMaterialKey = int.Parse(filter);
                return(response.Success(inventoryDelivery
                                        .Where(e => e.CatMaterialKey == catMaterialKey)
                                        .Select(e => new
                {
                    id = e.CatGeoLocationKey,
                    e.CatGeoLocation.Value
                })));
            }

            return(response.Success(inventoryDelivery.Select(e => new
            {
                id = e.CatGeoLocationKey,
                e.CatGeoLocation.Value
            })));
        }
示例#2
0
 public CommonResponse ReadbyName(MOTagHeader e)//by MO and Ln
 {
     CommonResponse response = new CommonResponse();
     if (e.MO != "" && e.MO_Ln != "")
     {
         using (CAPA_INVContext context = new CAPA_INVContext())
         {
             e = context.MOTagHeaders.FirstOrDefault(r => (r.MO == e.MO && r.MO_Ln == e.MO_Ln));
             if (e != null)
             {
                 response.Success(e, "OK");
                 return response;
             }
             else
             {
                 response.Error("MO Tag Header was not found.", null);
                 return response;
             }
         }
     }
     else
     {
         response.Error("MO and Ln can not be empty.", null);
         return response;
     }
 }
示例#3
0
        public CommonResponse ReadbyName(MOTagCount e)
        {
            CommonResponse response = new CommonResponse();

            if (e.Component_No != "")
            {
                using (CAPA_INVContext context = new CAPA_INVContext())
                {
                    e = context.MOTagCounts.FirstOrDefault(r => (r.Component_No == e.Component_No));
                    if (e != null)
                    {
                        response.Success(e, "OK");
                        return(response);
                    }
                    else
                    {
                        response.Error("MO Tag Line was not found.", null);
                        return(response);
                    }
                }
            }
            else
            {
                response.Error("Component can not be empty.", null);
                return(response);
            }
        }
示例#4
0
        public CommonResponse SendTestEmail([FromBody] string user)
        {
            CommonResponse response = new CommonResponse();
            User           entity;

            try
            {
                entity = JsonConvert.DeserializeObject <User>(user);

                EmailService email = new EmailService("secure.emailsrvr.com", 587);
                email.EmailAddress = entity.Email;
                email.Password     = entity.EmailPassword;

                email.From = entity.Email;
                email.To.Add(entity.Email);
                email.Subject = "Test Email from MRO System.";
                email.Body    = "This is a Test Email sent from MRO System.";

                email.SendMail();

                return(response.Success());
            }
            catch (Exception e)
            {
                return(response.Error("ERROR: " + e.ToString()));
            }
        }
示例#5
0
        public CommonResponse GetLastTagID(Ticket e)
        {
            CommonResponse response = new CommonResponse();

            using (CAPA_INVContext context = new CAPA_INVContext())
            {
                int?TagCounter;

                try
                {
                    TagCounter = context.Tickets.Where(q => q.InventoryEventKey == e.InventoryEventKey).Max(r => r.TicketCounter);
                }
                catch
                {
                    TagCounter = 0;
                }

                //Ticket _ticket = context.Tickets.Max(r => r.TicketCounter);
                if (TagCounter != null && TagCounter > 0)
                {
                    e.TicketCounter = Convert.ToInt32(TagCounter);
                    e = (Ticket)GetbyTagNo(e).Result;
                    response.Success(e, "OK");
                    return(response);
                }
                else
                {
                    response.Error("Ticket ID was not found.", null);
                    return(response);
                }
            }
        }
示例#6
0
        public async Task <IActionResult> GetCurrentUserRoles()
        {
            var currentUser = new User(User.Claims);
            var results     = await _roleBusiness.GetUserRoles(currentUser);

            return(Ok(CommonResponse.Success(results)));
        }
示例#7
0
        }//by COUNTER

        public CommonResponse ReadbyName(int Counter, int Active_IE_Key)///by counter
        {
            Ticket e = new CAP_Inventory_System.Ticket {
                TicketCounter = Counter, InventoryEventKey = Active_IE_Key
            };
            CommonResponse response = new CommonResponse();

            if (e.TicketCounter != 0)
            {
                using (CAPA_INVContext context = new CAPA_INVContext())
                {
                    e = context.Tickets.FirstOrDefault(r => (r.TicketCounter == e.TicketCounter && r.InventoryEventKey == e.InventoryEventKey));
                    if (e != null)
                    {
                        response.Success(e, "OK");
                        return(response);
                    }
                    else
                    {
                        response.Error("Ticket Counter was not found.", null);
                        return(response);
                    }
                }
            }
            else
            {
                response.Error("Ticket Counter can not be 0.", null);
                return(response);
            }
        }//by COUNTER
        public CommonResponse ReadbyId(FSTI_Transactions e)
        {
            CommonResponse response = new CommonResponse();

            if (e.id > 0)
            {
                using (CAPA_INVContext context = new CAPA_INVContext())
                {
                    e = context.FSTI_Transactions.FirstOrDefault(r => r.FSTI_Transaction_key == e.FSTI_Transaction_key);
                    if (e != null)
                    {
                        response.Success(e, "OK");
                        return(response);
                    }
                    else
                    {
                        response.Error("FSTI Transactions Id was not found.", null);
                        return(response);
                    }
                }
            }
            else
            {
                response.Error("User ID can not be 0.", null);
                return(response);
            }
        }
        public CommonResponse Create(FSTI_Transactions e)
        {
            CommonResponse response = new CommonResponse();

            using (CAPA_INVContext context = new CAPA_INVContext())
            {
                FSTI_Transactions t = new FSTI_Transactions();
                t = context.FSTI_Transactions.FirstOrDefault(r => (r.TagCountKey == e.TagCountKey));
                if (t == null)
                {
                    e.DateStampIn = DateTime.Now;
                    context.FSTI_Transactions.Add(e);
                    try
                    {
                        context.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        response.Error("Exception: " + ex.Message, null);
                        return(response);
                    }

                    response.Success(e, "OK");
                    return(response);
                }
                else
                {
                    response.Error("FSTI Transaction already exist.", null);
                    return(response);
                }
            }
        }
示例#10
0
        public CommonResponse GetActiveTrainings(int Level1Key)
        {
            CommonResponse response = new CommonResponse();

            var ctx = context as TrainingContext;

            var trainings = ctx.TrainingScores
                            .Include(e => e.Training)
                            .Where(e => e.Training.Level1Key == Level1Key)
                            .Where(e => e.Training.sys_active == true)
                            .GroupBy(e => new
            {
                e.EmployeeKey,
                e.Training.CertificationKey
            })
                            .Select(e => e.OrderByDescending(c => c.Training.DateExpiresAt).FirstOrDefault())
                            .Select(e => e.Training)
                            .ToList();


            foreach (var training in trainings)
            {
                training.TrainingScores = ctx.TrainingScores.Where(e => e.TrainingKey == training.TrainingKey).ToList();
                training.IsExpired      = training.DateExpiresAt < DateTimeOffset.Now;
                training.AboutToExpire  = training.DateExpiresAt < DateTimeOffset.Now.AddDays(30);
            }

            return(response.Success(trainings));
        }
示例#11
0
        public CommonResponse ReadbyId(FS_ItemMaster e) // FS ID
        {
            CommonResponse response = new CommonResponse();

            if (e.id > 0)
            {
                using (CAPA_INVContext context = new CAPA_INVContext())
                {
                    e = context.FS_ItemMaster.FirstOrDefault(r => r.ItemNumber_FSKey == e.ItemNumber_FSKey);
                    if (e != null)
                    {
                        response.Success(e, "OK");
                        return(response);
                    }
                    else
                    {
                        response.Error("Item Id was not found.", null);
                        return(response);
                    }
                }
            }
            else
            {
                response.Error("User ID can not be 0.", null);
                return(response);
            }
        }
        public CommonResponse ReadbyName(V_FSTI_Transaction e)
        {
            CommonResponse response = new CommonResponse();

            if (e.TransactionStringFields != "")
            {
                using (CAPA_INVContext context = new CAPA_INVContext())
                {
                    e = context.V_FSTI_Transaction.FirstOrDefault(r => r.TransactionStringFields.Contains(e.TransactionStringFields));
                    if (e != null)
                    {
                        response.Success(e, "OK");
                        return(response);
                    }
                    else
                    {
                        response.Error("Transaction Field was not found.", null);
                        return(response);
                    }
                }
            }
            else
            {
                response.Error("Transaction Field can not be empty.", null);
                return(response);
            }
        }
        public async Task <IActionResult> DeleteBookmarkByCourseId(long courseId)
        {
            var user    = new User(User.Claims);
            var results = await _bookmarkedCoursesBusines.DeleteBookmarkByCourseId(courseId, user);

            return(Ok(CommonResponse.Success(results)));
        }
        public async Task <IActionResult> GetAllBookmarks()
        {
            var user    = new User(User.Claims);
            var results = await _bookmarkedCoursesBusines.GetBookmarkedCoursesForUser(user.UserId);

            return(Ok(CommonResponse.Success(results)));
        }
示例#15
0
        public CommonResponse ReadbyName(cat_UserRole e)
        {
            CommonResponse response = new CommonResponse();

            if (e.UserRole != "")
            {
                using (CAPA_INVContext context = new CAPA_INVContext())
                {
                    e = context.cat_UserRole.FirstOrDefault(r => r.UserRole == e.UserRole);
                    if (e != null)
                    {
                        response.Success(e, "OK");
                        return(response);
                    }
                    else
                    {
                        response.Error("User Role Name was not found.", null);
                        return(response);
                    }
                }
            }
            else
            {
                response.Error("User Role Name can not be empty.", null);
                return(response);
            }
        }
示例#16
0
        public CommonResponse ReadbyId(InventoryEvent e)
        {
            CommonResponse response = new CommonResponse();

            if (e.id > 0)
            {
                using (CAPA_INVContext context = new CAPA_INVContext())
                {
                    e = context.InventoryEvents.FirstOrDefault(r => r.InventoryEventKey == e.id);
                    if (e != null)
                    {
                        response.Success(e, "OK");
                        return(response);
                    }
                    else
                    {
                        response.Error("Inventory Event Id was not found.", null);
                        return(response);
                    }
                }
            }
            else
            {
                response.Error("Inventory Event ID can not be 0.", null);
                return(response);
            }
        }
示例#17
0
        public CommonResponse Update(cat_UserRole e)
        {
            CommonResponse response = new CommonResponse();

            if (e.UserRole != "" && e.UserRoleDesc != "")
            {
                using (CAPA_INVContext context = new CAPA_INVContext())
                {
                    cat_UserRole entity = context.cat_UserRole.FirstOrDefault(r => r.UserRoleKey == e.UserRoleKey);

                    if (entity != null)
                    {
                        entity.UserRole     = e.UserRole;
                        entity.UserRoleDesc = e.UserRole;
                        context.SaveChanges();
                        response.Success(entity, "OK");
                        return(response);
                    }
                    else
                    {
                        response.Error("User Role does not exist.", null);
                        return(response);
                    }
                }
            }
            else
            {
                response.Error("User Role or Description can not be empty.", null);
                return(response);
            }
        }
示例#18
0
        public CommonResponse ReadbyName(FS_ItemMaster e)
        {
            CommonResponse response = new CommonResponse();

            if (e.ItemNumber != "")
            {
                using (CAPA_INVContext context = new CAPA_INVContext())
                {
                    e = context.FS_ItemMaster.FirstOrDefault(r => r.ItemNumber == e.ItemNumber);
                    if (e != null)
                    {
                        response.Success(e, "OK");
                        return(response);
                    }
                    else
                    {
                        response.Error("ItemNumber was not found.", null);
                        return(response);
                    }
                }
            }
            else
            {
                response.Error("ItemNumber can not be empty.", null);
                return(response);
            }
        }
示例#19
0
        public CommonResponse ReadbyName(InventoryEvent e)
        {
            CommonResponse response = new CommonResponse();

            if (e.InventoryEventName != "")
            {
                using (CAPA_INVContext context = new CAPA_INVContext())
                {
                    e = context.InventoryEvents.FirstOrDefault(r => r.InventoryEventName == e.InventoryEventName);
                    if (e != null)
                    {
                        response.Success(e, "OK");
                        return(response);
                    }
                    else
                    {
                        response.Error("Inventory Event Name was not found.", null);
                        return(response);
                    }
                }
            }
            else
            {
                response.Error("Inventory Event Name can not be empty.", null);
                return(response);
            }
        }
示例#20
0
 public CommonResponse ReadbyId(MOTagHeader e)
 {
     CommonResponse response = new CommonResponse();
     if (e.MOTagHeaderKey > 0)
     {
         using (CAPA_INVContext context = new CAPA_INVContext())
         {
             e = context.MOTagHeaders.FirstOrDefault(r => r.Ticket.TicketKey == e.Ticket.TicketKey);
             if (e != null)
             {
                 response.Success(e, "OK");
                 return response;
             }
             else
             {
                 response.Error("MO Tag Header was not found.", null);
                 return response;
             }
         }
     }
     else
     {
         response.Error("Inventory Event ID can not be 0.", null);
         return response;
     }
 }
示例#21
0
        public CommonResponse SendMail()
        {
            CommonResponse response = new CommonResponse();

            try
            {
                server.EnableSsl             = true;
                server.DeliveryMethod        = SmtpDeliveryMethod.Network;
                server.UseDefaultCredentials = false;
                server.Credentials           = new System.Net.NetworkCredential(EmailAddress, Password);

                MailMessage message = new MailMessage();
                message.From = new MailAddress(From, From);

                foreach (var to in To)
                {
                    message.To.Add(new MailAddress(to));
                }
                message.Subject      = Subject;
                message.IsBodyHtml   = true;
                message.BodyEncoding = System.Text.Encoding.UTF8;

                message.Body = Body;

                server.Send(message);
            }
            catch (System.Exception ex)
            {
                return(response.Error(ex.Message));
            }

            return(response.Success());
        }
示例#22
0
        public static CommonResponse CreateSuccess(string message, string messageCode, object result)
        {
            var response = new CommonResponse();

            response.Success(message, messageCode, result);

            return(response);
        }
        public async Task <IActionResult> CreateBookmark([FromBody] BookmarkedCourse bookmark)
        {
            var user = new User(User.Claims);

            bookmark.User = user;
            var results = await _bookmarkedCoursesBusines.CreateBookmark(bookmark);

            return(Ok(CommonResponse.Success(results)));
        }
        public async Task <IActionResult> AddEnrollmentsForCourse([FromBody] Enrollment enrollment)
        {
            var user = new User(User.Claims);

            enrollment.CreatedBy = user;
            var results = await _enrollmentBusiness.CreateEnrollment(enrollment);

            return(Ok(CommonResponse.Success(results)));
        }
        public async Task <IActionResult> CreateContentItem([FromBody] ContentItem item, long courseId)
        {
            var user = new User(User.Claims);

            item.CreatedBy = user;
            item.Course    = await _courseBusiness.GetCourseById(courseId);

            var results = await _contentItemBusiness.CreateContentItem(item);

            return(Ok(CommonResponse.Success(results)));
        }
        public async Task <IActionResult> FindCourse(string q)
        {
            if (q == null || q.Length <= 3)
            {
                return(BadRequest(CommonResponse.Fail(
                                      "Due to the volume of courses, the search term will need to be greater than 3 characters")));
            }

            var results = await _courseBusiness.FindCourse(q);

            return(Ok(CommonResponse.Success(results)));
        }
示例#27
0
        public CommonResponse getByUserName(string userName)
        {
            CommonResponse response = new CommonResponse();

            try
            {
                response.Success(logic.GetSingleWhere(u => u.UserName == userName));
            }
            catch (Exception ex)
            {
                return(response.Error(ex.ToString()));
            }
            return(response);
        }
示例#28
0
        public CommonResponse getByRole(string role)
        {
            CommonResponse response = new CommonResponse();

            try
            {
                response.Success(_logic.GetListWhere(u => u.Value, u => u.Role == role));
            }
            catch (Exception ex)
            {
                return(response.Error(ex.ToString()));
            }
            return(response);
        }
示例#29
0
        ///start:slot:logic<<<

        public CommonResponse GetInventory()
        {
            var            response       = new CommonResponse();
            FilterResponse filterResponse = new FilterResponse();

            var ctx = context as MROContext;

            var inventory = ctx.InventoryInputs.GroupBy(e => new
            {
                e.CatMaterial
                //, e.CatUnitOfMeasure
            }).Select(e => new
            {
                e.Key,
                e.Key.CatMaterial.Value,
                e.Key.CatMaterial.MaterialDescription,
                e.Key.CatMaterial.Min,
                BalanceSum = e.Sum(b => b.Balance),
                id         = e.Key.CatMaterial.CatMaterialKey
            });
            var filter = HttpContext.Current.Request["filterGeneral"];

            if (!string.IsNullOrWhiteSpace(filter) && filter != null && filter != "undefined")
            {
                inventory = inventory.Where(e => e.Key.CatMaterial.Value.Contains(filter));
            }
            var page = HttpContext.Current.Request["page"];

            if (!string.IsNullOrWhiteSpace(page) && page != null && page != "undefined")
            {
                var perPage = HttpContext.Current.Request["perPage"];

                if (!string.IsNullOrWhiteSpace(perPage) && perPage != null && perPage != "undefined")
                {
                    int iPage    = int.Parse(page);
                    int iPerPage = int.Parse(perPage);


                    filterResponse.total_items = inventory.Count();
                    //TODO FILTER
                    filterResponse.total_filtered_items = inventory.Count();

                    inventory = inventory.OrderBy(e => e.Value).Skip((iPage - 1) * iPerPage).Take(iPerPage);
                }
            }


            return(response.Success(inventory.ToList(), filterResponse));
        }
示例#30
0
        //Specific for UserLogic
        public CommonResponse GetByName(string sName)
        {
            CommonResponse response = new CommonResponse();

            try
            {
                User entity = repository.GetSingle(null, e => e.UserName == sName);
                AdapterOut(entity);
                return(response.Success(entity));
            }
            catch (Exception e)
            {
                return(response.Error("ERROR: " + e.ToString()));
            }
        }