Пример #1
0
        public int CreateCalendar(string loginedUserId, string name, int colorId, Access access)
        {
            var color    = serviceHelper.WrapMethodWithReturn(() => colorRepos.GetColorById(colorId), null);
            var calendar = new Calendar
            {
                Name   = name,
                Color  = color == null ? null : Mapper.Map <Data.Models.Color, Color>(color),
                Access = access
            };


            var dataUser = serviceHelper.GetUserByIdentityId(loginedUserId);

            if (dataUser != null)
            {
                var dCalendar  = Mapper.Map <Calendar, Data.Models.Calendar>(calendar);
                var calendarId = serviceHelper.WrapMethodWithReturn(() => calendarRepos.CreateCalendar(dataUser.IdUser, dCalendar), -1);
                return(calendarId);
            }
            return(-1);
        }