/// <summary>
        /// Get occurrence form to create.
        /// </summary>
        /// <returns></returns>
        public async Task <ActionResult> GetCreateOccurrence()
        {
            OccurrenceFormData occurrenceFormData = new OccurrenceFormData
            {
                OccurrenceStartDate = DateTime.Now.ToString("dd/MM/yyyy"),
                OccurrenceEndDate   = DateTime.Now.ToString("dd/MM/yyyy"),
                TranslationsList    = new List <OccurrenceTranslationFormData>()
            };
            LanguageResultData result =
                await WebApiClient.GetAsync <LanguageResultData>(Constant.WebApiControllerLanguages,
                                                                 Constant.WebApiLanguageList);

            if (result != null && result.OperationSuccess && result.LanguageDtoList != null)
            {
                foreach (var language in result.LanguageDtoList)
                {
                    var translation = new OccurrenceTranslationFormData
                    {
                        LanguagePrefix = language.LanguagePrefix,
                        LanguageId     = language.LanguageId
                    };
                    occurrenceFormData.TranslationsList.Add(translation);
                }
            }
            ViewBag.Action = "CreateOccurrence";
            return(PartialView("Partials/_ManageOccurrence", occurrenceFormData));
        }
Beispiel #2
0
        /// <summary>
        /// From FORMDATA To REQUEST DATA
        /// </summary>
        /// <param name="occurrenceTranslationFormData">form data to convert</param>
        /// <returns></returns>
        public static OccurrenceTranslationRequestData ToRequestData(this OccurrenceTranslationFormData occurrenceTranslationFormData)
        {
            if (occurrenceTranslationFormData == null)
            {
                return(new OccurrenceTranslationRequestData());
            }

            return(new OccurrenceTranslationRequestData
            {
                OccurrenceTranslationDtoList = new List <OccurrenceTranslationItemData>(),
                OccurrenceTranslationDto = occurrenceTranslationFormData.ToItemData()
            });
        }
Beispiel #3
0
        /// <summary>
        /// FROM FROM DATA TO ITEM DATA.
        /// </summary>
        /// <param name="formData">the form data to convert.</param>
        /// <returns>the item data.</returns>
        public static OccurrenceTranslationItemData ToItemData(this OccurrenceTranslationFormData formData)
        {
            if (formData == null)
            {
                return(new OccurrenceTranslationItemData());
            }

            return(new OccurrenceTranslationItemData
            {
                OccurrenceDescription = formData.OccurrenceDescription,
                OccurrenceTitle = formData.OccurrenceTitle,
                TranslationId = formData.TranslationId,
                LanguageId = formData.LanguageId,
                OccurrenceId = formData.OccurrenceId
            });
        }
Beispiel #4
0
        /// <summary>
        /// FROM itemData TO FORM DATA.
        /// </summary>
        /// <param name="itemData"></param>
        /// <returns></returns>
        public static OccurrenceTranslationFormData ToFormData(this OccurrenceTranslationItemData itemData)
        {
            if (itemData == null)
            {
                return(new OccurrenceTranslationFormData());
            }

            OccurrenceTranslationFormData formData = new OccurrenceTranslationFormData
            {
                OccurrenceDescription = itemData.OccurrenceDescription,
                LanguagePrefix        = itemData.Language.LanguagePrefix,
                OccurrenceTitle       = itemData.OccurrenceTitle,
                OccurrenceId          = itemData.OccurrenceId ?? 0,
                TranslationId         = itemData.TranslationId,
                LanguageId            = itemData.LanguageId ?? 0
            };

            return(formData);
        }
        /// <summary>
        /// validate create occurrence translation.
        /// </summary>
        /// <param name="occurrenceTranslationFormData">the occurrenceTranslationFormData to validate.</param>
        /// <returns>true if the proportises are valide.</returns>
        public bool ValidateOccurrenceTranslationFormData(OccurrenceTranslationFormData occurrenceTranslationFormData)
        {
            List <string> errors = new List <string>();

            if (occurrenceTranslationFormData == null)
            {
                errors.Add(SharedResources.NullFormData);
            }
            else
            {
                errors.AddRange(GenericValidationAttribute <OccurrenceTranslationFormData> .ValidateAttributes(
                                    "OccurrenceDescription", occurrenceTranslationFormData.OccurrenceDescription));
                errors.AddRange(
                    GenericValidationAttribute <OccurrenceTranslationFormData> .ValidateAttributes("LanguageId",
                                                                                                   occurrenceTranslationFormData.LanguageId.ToString()));
                errors.AddRange(
                    GenericValidationAttribute <OccurrenceTranslationFormData> .ValidateAttributes("OccurrenceTitle",
                                                                                                   occurrenceTranslationFormData.OccurrenceTitle));
            }
            return(errors.Count == 0);
        }