public JsonResult SaveLanguagesData(LanguagesDTO languagesDetail)
        {
            var AllStatus = languagesData.AddLanguagesData(languagesDetail);

            return(new JsonResult {
                Data = AllStatus, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemplo n.º 2
0
 public Language CastToDAL(LanguagesDTO l)
 {
     return(new Language()
     {
         languageId = l.languageId,
         name = l.name
     });
 }
Exemplo n.º 3
0
        private int UpdateLanguages(LanguagesDTO languages)
        {
            int    LanguageId      = 0;
            string updateProcedure = "[CreateLanguages]";

            SqlCommand updateCommand = new SqlCommand(updateProcedure, connection);

            updateCommand.CommandType = CommandType.StoredProcedure;


            if (languages.LanguageId != 0)
            {
                updateCommand.Parameters.AddWithValue("@LanguageId", languages.LanguageId);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@LanguageId", 0);
            }
            if (!string.IsNullOrEmpty(languages.LanguageName))
            {
                updateCommand.Parameters.AddWithValue("@LanguageName", languages.LanguageName);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@LanguagesName", DBNull.Value);
            }

            updateCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
            updateCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
            try
            {
                int count = 0;
                connection.Open();
                updateCommand.ExecuteNonQuery();
                if (updateCommand.Parameters["@ReturnValue"].Value != DBNull.Value)
                {
                    count = System.Convert.ToInt32(updateCommand.Parameters["@ReturnValue"].Value);
                }

                return(LanguageId);
            }
            catch (Exception ex)
            {
                log.logErrorMessage("");
                log.logErrorMessage(ex.StackTrace);
                return(LanguageId);
            }
            finally
            {
                connection.Close();
            }
        }
Exemplo n.º 4
0
        private LanguagesDTO AddLanguages(LanguagesDTO languages)
        {
            string insertProcedure = "[CreateLanguages]";

            SqlCommand insertCommand = new SqlCommand(insertProcedure, connection);

            insertCommand.CommandType = CommandType.StoredProcedure;


            if (languages.LanguageId != 0)
            {
                insertCommand.Parameters.AddWithValue("@LanguageId", languages.LanguageId);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@LanguageId", 0);
            }

            if (!string.IsNullOrEmpty(languages.LanguageName))
            {
                insertCommand.Parameters.AddWithValue("@LanguageName", languages.LanguageName);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@LanguagesName", DBNull.Value);
            }
            if (languages.CustId != 0)
            {
                insertCommand.Parameters.AddWithValue("@CustID", languages.CustId);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@CustID", 0);
            }

            if (languages.UserID != 0)
            {
                insertCommand.Parameters.AddWithValue("@UserID", languages.UserID);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@UserID", 0);
            }
            if (languages.IsActive)
            {
                insertCommand.Parameters.AddWithValue("@IsActive", languages.IsActive);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@IsActive", 0);
            }
            if (languages.Type != 0)
            {
                insertCommand.Parameters.AddWithValue("@StatementType", languages.Type);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@StatementType", 0);
            }

            insertCommand.Parameters.Add("@LanguageIdout", System.Data.SqlDbType.Int);
            insertCommand.Parameters["@LanguageIdout"].Direction = ParameterDirection.Output;

            insertCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
            insertCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;
            try
            {
                int count = 0;
                connection.Open();
                insertCommand.ExecuteNonQuery();
                if (insertCommand.Parameters["@ReturnValue"].Value != DBNull.Value)
                {
                    count            = System.Convert.ToInt32(insertCommand.Parameters["@ReturnValue"].Value);
                    languages.Status = count;
                }
                if (count != 0 && languages.LanguageId == 0)
                {
                    languages.LanguageId = System.Convert.ToInt32(insertCommand.Parameters["@LanguageIdout"].Value);
                }
                return(languages);
            }
            catch (Exception ex)
            {
                log.logErrorMessage("");
                log.logErrorMessage(ex.StackTrace);
                return(languages);
            }
            finally
            {
                connection.Close();
            }
        }
Exemplo n.º 5
0
        public List <dynamic> AddLanguagesData(LanguagesDTO languagesDetail)
        {
            List <dynamic> objDynamic = new List <dynamic>();

            #region comment
            //var Data = JsonConvert.DeserializeObject<List<LanguagesDTO>>(languagesDetail.Languagesdet);
            //for (int i = 0; i < Data.Count; i++)
            //{
            //    languages = Data[i];
            //    if (!String.IsNullOrEmpty(languages.LanguageName))
            //    {
            //        if (languages.IsChange)
            //        {
            //            if (!string.IsNullOrEmpty(UserID))
            //            {
            //                languages.UserID = Convert.ToInt64(UserID);
            //            }
            //            if (languages.LanguageId != 0 )
            //            {
            //                languages.Type = 2;
            //            }

            //            if (languages.IsDelete == true)
            //            {
            //                languages.Type = 3;
            //                languages.IsActive = false;
            //            }

            //            AddLanguages(languages);
            //            if (languages.Status == -99)
            //            {
            //                objDynamic.Add(languages.Status);
            //                break;
            //            }
            //            else
            //            {
            //                objDynamic.Add(languages.Status);
            //            }
            //        }

            //    }

            // }

            #endregion
            CustLanguages custLanguages = new CustLanguages();
            LanguagesDTO  languages     = new LanguagesDTO();



            try
            {
                switch (languagesDetail.Type)
                {
                case 1:
                {
                    var Data = JsonConvert.DeserializeObject <List <LanguagesDTO> >(languagesDetail.Languagesdet);
                    for (int i = 0; i < Data.Count; i++)
                    {
                        languages = Data[i];
                        if (languages.IsChange && languages.IsDelete)
                        {
                            languages.IsActive = false;
                            languages.Type     = 3;
                            if (!string.IsNullOrEmpty(UserID))
                            {
                                languages.UserID = Convert.ToInt64(UserID);
                            }
                            AddLanguages(languages);
                        }
                    }
                    break;
                }

                case 2:
                {
                    var   Data = JsonConvert.DeserializeObject <List <CustLanguages> >(languagesDetail.Customerdet);
                    Int64 val  = languagesDetail.LanguageId;

                    for (int i = 0; i < Data.Count; i++)
                    {
                        custLanguages          = Data[i];
                        languages.CustId       = custLanguages.CustId;
                        languages.LanguageName = languagesDetail.LanguageName;
                        if (!string.IsNullOrEmpty(UserID))
                        {
                            languages.UserID = Convert.ToInt64(UserID);
                        }
                        if (val != 0)
                        {
                            languages.IsActive   = custLanguages.IsCat;
                            languages.Type       = 2;
                            languages.LanguageId = val;

                            AddLanguages(languages);
                        }
                        else
                        {
                            languages.IsActive   = custLanguages.IsCat;
                            languages.Type       = 1;
                            languages.LanguageId = val;

                            AddLanguages(languages);
                            val = languages.LanguageId;
                            if (languages.Status != 1)
                            {
                                break;
                            }
                        }
                    }
                    break;
                }
                }
            }
            catch (Exception ex)
            {
            }


            //AddLanguages(languages);
            objDynamic.Add(languages.Status);
            objDynamic.Add(GetLanguagesData(0));
            return(objDynamic);
        }