Ejemplo n.º 1
0
        public ExecuteResultEntity <string> GetNextProjectSerialNumber(string year)
        {
            var result = (from q in projectsrepo.All()
                          where q.Code.StartsWith(year.Trim()) && q.Void == false
                          orderby q.Code descending
                          select q.Code).FirstOrDefault();

            if (!string.IsNullOrEmpty(result))
            {
                string[] parts = result.Split('-');

                if (parts.Any() && parts.Length >= 1)
                {
                    int currentNumber = 0;

                    if (int.TryParse(parts[1], out currentNumber))
                    {
                        currentNumber += 1;
                        return(ExecuteResultEntity <string> .CreateResultEntity(string.Format("{0:000}", currentNumber)));
                    }
                }
            }

            return(ExecuteResultEntity <string> .CreateResultEntity("001"));
        }